5

i have made this example work on my page http://datatables.net/examples/server_side/server_side.html, (using php5, jquery+ui and dataTables.net)

i would like to be able to add a Modify and Delete link on each row, how can i do that without sending two extra columns with the links from the server?

also how can i substitute the ids the rows have in the database and that are sent by the server with nice number starting from 1 till iTotalDisplayRecords...

thank you

2
  • What wrong with sending the two columns? Commented Jan 18, 2011 at 9:03
  • 2
    it looks like a bad solution to me, sending extra data to every ajax request, sending html code for links, what if path changes one day... it would be simplier if javascript could add it on the fly Commented Jan 18, 2011 at 9:08

1 Answer 1

4

found how

var controller_name = '<?php echo Zend_Controller_Front::getInstance()->getRequest()->getControllerName();?>';


"fnDrawCallback": function ( oSettings ) {
                    /* Need to redo the counters if filtered or sorted */

                        for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
                        {
                            var link = $('&nbsp;<a href="/'+controller_name+'/modifica/id/'+ oSettings.aoData[ oSettings.aiDisplay[i] ]._aData[0]+'">Modifica</a> <a href="/'+controller_name+'/cancella/id/'+ oSettings.aoData[ oSettings.aiDisplay[i] ]._aData[0]+'">Cancella</a>');
                            $('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html( i+1 );
                            $('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).append(link);
                        }
                },
Sign up to request clarification or add additional context in comments.

1 Comment

using fnRowCallback is much faster and responsive than fnDrawCallback!!! (when having more than 500rows or stuff) and it doesn't give errors about script not responding

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.