Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding working buttons. #16

Open
Wmas opened this issue Jan 9, 2016 · 4 comments
Open

Adding working buttons. #16

Wmas opened this issue Jan 9, 2016 · 4 comments

Comments

@Wmas
Copy link

Wmas commented Jan 9, 2016

Hi Paul,
This is absolute a nice library to use with Codeigniter. It works just as expected. But only searching on the table wouldn't be the only thing you want to do with your records.
Any chance that you would add some methods to let the user add custom controls on each row with the needed Id's?.

At the moment you can not pass HTML elements from the model to the view because the appendToSelectStr() method don't support it.

I think this improvement will make this library more usefull and popular for the CodeIgniter comunity.

Thanks for sharing this, I havo also visited your site where you have posted many useful snippets, I will advise anyone to go there and have a look at it

:) Cheers

Franco

@zepernick
Copy link
Owner

Sorry for the very late reply. This should be done using JavaScript and DataTables Api. I am posting from my phone right now and will follow up with a example later.

@gastongr
Copy link

Hello, just wanted to say that i really appreciate you sharing this excelent library with everyone. Thanks so much!

As for the question, here is a post in which Zepernick showed an example of the described method. http://forum.codeigniter.com/archive/index.php?thread-725-2.html

I have a question regarding this method.
Traditionally, without using datatables, i would echo the buttons of each row in php like this:

Delete

So that i could attach an action to that button and pickup the id but also a confimation message for the buton's action. This message was generated on the server since its language dependant.

Do you have any ideas on how to implement a similar functionality using datatables?

Thanks again for sharing your great work!

Gaston

@gastongr
Copy link

Ouch my message got cropped, i'll try again.
Traditionally, without using datatables, i would echo the buttons for each row in php like this:

<span class="btn btn-xs" data-confirm-message="<?php echo $this->lang->line('msg_confirm'); ?>">Delete</span>

Then i would attach an action to the button using jquery and pickup the id and confirmation message from data attrubutes. You showed how to pick up the id, but do you have any idea on how to include a server generated string for each row,? in this case it would contain a simple translation of a message to use as confirmation for the delete action.

Any advice is welcome.
Thanks again for sharing your excelent work with everyone!

Gaston

@gastongr
Copy link

Just for the record, i solved it using the fnCreatedRow callback to add a custom data-attribute to each row which then i pick up on the buttons action.
http://legacy.datatables.net/usage/callbacks
Regards!
Gaston

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants