Apply server side filters on click

Apply server side filters on click

tknight1984tknight1984 Posts: 3Questions: 0Answers: 0
edited April 2013 in General
Hello,

I am using your excellent plugin and have managed to get most functionality required with ease. One requirement outstanding is the ability to only apply filters once an "Apply Filters" button is clicked. I have it working by iterating through each of my filters and calling fnFilter

[code] $("#btnApplyFilters").click(function () {

$("thead input[type=text]").each(function (i) {
alert("about to add")
oTable.fnFilter(this.value, $("thead input[type=text]").index(this));
alert("added")
});
oTable.fnDraw();
});
[/code]

Unfortunately, the call to fnFilter causes an ajax call to repopulate the grid. So if the user is trying to apply 3 filters, each call to fnFilter will cause a call to the server.

Is there anyway i can apply all the filters in one go on a button click?

Many thanks,

Tom

Replies

  • tknight1984tknight1984 Posts: 3Questions: 0Answers: 0
    Has no one ever requested this before?
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Most DataTables API methods have the option to not do a draw, but it looks like fnFilter is missing this option :-(. This will be resolved with the new API in DataTables 1.10, but at the moment it would require a change in the fnFilter code, or putting together a plug-in API that will manipulate the internal settings as required.

    I'm surprised that this hasn't come up before myself (or if it has, I've clean forgotten about it :-( ). But as I say, 1.10 will resolve this.

    Allan
  • tknight1984tknight1984 Posts: 3Questions: 0Answers: 0
    Thank you allan, do you have a release date for 1.10?

    I am happy to suffer the additional server hit at the moment as it is very rare that someone will apply more than one filter.
This discussion has been closed.