I am using jQuery Datatables plugin and I want to add some extra content (complex filters) to page that I have my table.
Normally, controller action method is called by plugin, when I search something, sort the columns and so on.
What I want to achieve is to call this action method manually (via Ajax) and pass my complex filter data to it in addition to parameters that plugin is normally passing.
Is this possible ? I believe there has to be a way, since there is a plugin for column type based filtering. ( I think it should be doing something very similar )
I am using datatables with ASP.NET MVC if it matters.
Thanks.
It is quite simple actually. I have done it plenty of times so I’ll give you some of the code I use.
JS:
Now in the Controller:
You will need to add the following object to get the data from the aoData object:
Now my function didn’t include serverside ordering so here is an example of that:
Then you can return the SLAList.
I know this is a lot of code and examples. I can explain any specifics if you want.
Also I’m using ADO.NET but you can use SQL or w/e for your data, works the same.
Oh and to refresh the data manually you can take a look at this question : how can I trigger jquery datatables fnServerData to update a table via AJAX when I click a button?