Reputation: 1945
I added plugin
$.fn.dataTableExt.oApi.fnGetColumnData
Can be found here: http://datatables.net/plug-ins/api
After I executed
$(document).ready(function () {
var oDataTable = $("#usersGrid").dataTable();
//...
}
Microsoft JScript runtime error: Unable to get value of the property 'asSorting': object is null or undefined.
What can be a reason?
P.S.: It's not fnGetColumnData problem but another one which connected with $("#usersGrid").dataTable();
$('#example').dataTable({
"sDom": 'R<"H"lfr>t<"F"ip<',
"bJQueryUI": true,
"bFilter": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "sTitle": "A" },
{ "sTitle": "B" },
{ "sTitle": "C" }
]
});
Upvotes: 3
Views: 8211
Reputation: 71
It's true that dataTables need an html table with <thead>
and a <th>
for each column. An easier fix however, is to simply add the following line in the code behind, immediately after the databind()
call.
MyGridView.DataSource = <some data source>
MyGridView.DataBind();
MyGridView.HeaderRow.TableSection = TableRowSection.TableHeader; // wraps header row with THEAD element for sorting
Upvotes: 0
Reputation: 76880
I think that this has something to do with your markup. Remember that dataTables needs an html table with <thead>
section with a <th>
for each column. If you are trying to initialize an empty table you should try
$('#usersGrid').dataTable({
aoData: [{}]
});
Upvotes: 6