zepernick / Codeigniter-DataTables

CodeIgniter Library For Ajax Server Side DataTables 1.10 >
MIT License
94 stars 95 forks source link

Adding working buttons. #16

Open Wmas opened 8 years ago

Wmas commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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