Adding fnFooterCallback function in .NET MVC
Adding fnFooterCallback function in .NET MVC
geminirand
Posts: 4Questions: 0Answers: 0
I have the datatables working fine in ASP .NET MVC, the code below:
@section onReady{
var oTable;
/* Initialize table and make first column non-sortable*/
oTable = $('#services').dataTable({
"iDisplayLength": 100,
bStateSave: true,
aLengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"bJQueryUI": true,
"aoColumns": [ null, null, null,
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false } ]
});
}
And here is my html table:
Email/Username
First Name
Last Name
Manage
@foreach (var item in Model) {
@Html.ActionLink(item.UserName, "Edit", new { id=item.UserID })
@item.FirstName
@item.LastName
@Html.ActionLink("Customers", "AssociateCustomer", new { id=item.UserID })
@Html.ActionLink("Devices", "ManageDevices", new { id=item.UserID })
@Html.ActionLink("Status", "ManageStatus", new { id=item.UserID })
@Html.ActionLink("Screens", "ManageScreens", new { id=item.UserID })
}
Total
I'm trying to add this code but don't know where. I keep getting a parser error about needing another brace } Which portion of this code do I need (do I still need the first line?) and where do I put the rest?
$(document).ready( function() {
$('#example').dataTable( {
"fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay ) {
nFoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+iStart;
}
} );
} )
Thanks
@section onReady{
var oTable;
/* Initialize table and make first column non-sortable*/
oTable = $('#services').dataTable({
"iDisplayLength": 100,
bStateSave: true,
aLengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"bJQueryUI": true,
"aoColumns": [ null, null, null,
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false } ]
});
}
And here is my html table:
Email/Username
First Name
Last Name
Manage
@foreach (var item in Model) {
@Html.ActionLink(item.UserName, "Edit", new { id=item.UserID })
@item.FirstName
@item.LastName
@Html.ActionLink("Customers", "AssociateCustomer", new { id=item.UserID })
@Html.ActionLink("Devices", "ManageDevices", new { id=item.UserID })
@Html.ActionLink("Status", "ManageStatus", new { id=item.UserID })
@Html.ActionLink("Screens", "ManageScreens", new { id=item.UserID })
}
Total
I'm trying to add this code but don't know where. I keep getting a parser error about needing another brace } Which portion of this code do I need (do I still need the first line?) and where do I put the rest?
$(document).ready( function() {
$('#example').dataTable( {
"fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay ) {
nFoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+iStart;
}
} );
} )
Thanks
This discussion has been closed.
Replies
oTable = $('#services').dataTable({
"iDisplayLength": 100,
aLengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
bStateSave: true,
"bJQueryUI": true,
"aoColumns": [
{ "bSortable": false, "bSearchable": false },
null,
null,
null, null, null, null ]
,
"fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay )
{
nFoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+iStart;
}
});