reloading all data with Ajax and redraw the table

reloading all data with Ajax and redraw the table

dedeisepdedeisep Posts: 3Questions: 0Answers: 0
edited June 2010 in General
Hi everybody and thank you for this plugin

However I'm facing some issue with datatable search feature.
Here is what I'm suppose to do:
The user type a research keyword.
This keyword is sent by Ajax to the server which retrieve all research results at once (no pagination, filtering from the server)
a jQuery ui dialog pops and display a datatable containing all the results.

I'm initiating datatable this way:
// In dom Ready event $('#searchDialog').dialog({autoOpen : false, width : 500, 'title' : "search results"}) table = $('#searchResults').dataTable({ "aaData" : [], //No data at the begining "bProcessing": true, "bAutoWidth" : false, "fnRowCallback": function( nRow, aData, iDisplayIndex ) { $(nRow).attr('rel',aData[3]); //easy retrieve the hidden column return nRow; }, "aoColumns": [ null, null, null, {"bVisible" : false, "bSearchable" : false}, ]});
So the table is empty at first sight (but the dialog box is closed).
I also have a button to perform the research via a post request. Here is the function triggered when results are obtained from server

formfunctions = { /*.....*/ openProposal : function(rep){ table.fnClearTable(); //Clear the old data for(var i in rep) table.fnAddData( [rep[i].name , rep[i].city , rep[i].zip , rep[i].href] , false ); //add new data without redrawing the table $('#searchDialog').dialog('open'); //Open the jquery ui dialog box table.fnDraw(true); //draw the table }, /* .... */ }
This function seems to work at first sight:
"table" is filled with server results,
"table" supports pagination and ordering features,
But the problem is that it doesn't handle filtering at all. Each time I'm typing a letter, it doesn't find anything and display the "no results" message.

I tryed to put data in it at the begining, datatable filtering feature was working as long as I wouldn't reload the table my way.

I tryed to search but I didn't find any answer on this forum,

Replies

  • dedeisepdedeisep Posts: 3Questions: 0Answers: 0
    I forgot to mention I'm using jQuery 1.3 and datatable 1.6.2

    Thanks for your reply
  • dedeisepdedeisep Posts: 3Questions: 0Answers: 0
    I'm sorry,
    I finally found the solution,
    My server data were not valid, I had trailing \r\n in the end of some of my records. Triming data server side worked.

    However, isn't datatable supposed to deal with those \r\n?

    Thank you!
This discussion has been closed.