1

My point is... i have a dataTable with over 20k records, so i'm server side processing it, so the user browser stays sharp.

But, i have buttons i must 'assembly' to edit, remove or activate some records, and when i try to put html on the return of the server side processing, i get an error from dataTable, even if my json is well formatted...

so, what can i do?

I've tried using fnDrawCallback, but it runs after the data placement on the table.

Thanks in advance, Jorge Ferrari.

3
  • 1
    What is the error you receive from dataTable? Commented Mar 28, 2014 at 13:06
  • If you want to run callback before data placement, try fnPreDrawCallback Commented Mar 28, 2014 at 13:09
  • preDraw din't work as well :/ Commented Mar 28, 2014 at 13:10

2 Answers 2

2

If I understand correctly, you can build html controls using mRender in your column definitions. I have used this to create edit links on each datatable row using a value returned by the json data as a dynamic parameter:

    'aoColumns': [
                 {
                  'mRender': function (data, type, row) {
                           var EditLinkText = ' |<a href=\'Edit/' + row[10] + '\'>Edit</a>';
                           return EditLinkText;
                  }
             }
           ]
Sign up to request clarification or add additional context in comments.

Comments

1

I just find out how i may do it.

i can use the fnServerData.. here's an example

// POST data to server
$(document).ready( function() {
  $('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "xhr.php",
    "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
       oSettings.jqXHR = $.ajax( {
    "dataType": 'json',
    "type": "POST",
    "url": sSource,
    "data": aoData,
    "success": fnCallback
      } );
    }
  } );
} );

Comments

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.