I downloaded the Jquery Data Table and the Jquery DataTable.Filter Plugin.
Here is the code i am working on.
var oTable = $('#myDataTable').dataTable({
"bServerSide": true,
"sAjaxSource": "/User/DataProviderAction",
"bJQueryUI": true
});
oTable.columnFilter({ sPlaceHolder: "head:before",
aoColumns: [{ type: "select", values: ["Box Office", "Concessions"] },
{ type: "select",values: ["Administrator","Sales People"]},
{type: "text"}
]
});
QUESTION: Instead of hardcoding the values in aoColumns how would I go about getting it to load values from the database. I am using MVC. I do have a method set up returning string values in my repository, if that helps.
You could retreive your database values from from your controller by doing a jquery ajax call and then setting Javascript variables to the response value which you can use in your datatable. I’ve got a pseudo example below.
Your controller would return a Json response, which could be a Model:
If your doing a Post from the ajax call, remember to include the [HttpPost] attribute on the Controller Action.