Serverside filtering with intial column filter

Serverside filtering with intial column filter

markvrmarkvr Posts: 2Questions: 0Answers: 0
edited May 2011 in General
I've got server side filtering working with text boxes to search on individual columns and it works great to filter after the initial table draw.

However, I'd like to be able to provide an initial search term in the URL. e.g. page.html?person_id=123456
then populates the columns text box, and hence the server query. At the moment I can do it like:

[code]
$(document).ready(function(){

nTable = $('#notifications').dataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
],
"aaSorting": [[1, 'desc']],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "https://server/getNotifications",
"fnDrawCallback":redraw
});

if ($.url.param("person_id")) {
$("#n_personid_filter").val($.url.param("person_id"));
nTable.fnFilter( $.url.param("person_id"), 2 );
}
[/code]

This works, but it is messy because it actually draws the table, then redraws it with the filter so makes 2 ajax calls.

Is there a way of providing an initial column filter (i.e. not a global one using oSearch) before initialising datatables?

cheers!!
Mark

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    http://datatables.net/usage/options#aoSearchCols :-)

    Allan
  • markvrmarkvr Posts: 2Questions: 0Answers: 0
    dammit :)

    I read the docs backwards and forwards but only found oSearch...

    thanks!
This discussion has been closed.