Created
December 9, 2014 10:23
-
-
Save velyo/db1518e2c425baabd9e5 to your computer and use it in GitHub Desktop.
jQuery DataTable sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DataGrid() { | |
this.sDom = 'CT<"clear">Rlfrtip'; | |
// TableTool options | |
this.oLanguage = { | |
// Remove the word entries | |
"sLengthMenu" : "Show _MENU_", | |
}; | |
// Disable sorting on columns with class="sort-no" | |
this.aoColumnDefs = [ | |
{ | |
"bSortable" : false, | |
"aTargets" : [ "sort-no" ] | |
}, | |
{ | |
"aTargets": [0], | |
"mData": null, | |
"mRender": function (data, type, row) { | |
var buffer = []; | |
buffer.push('<button title="Edit" data-id="'); | |
buffer.push(row[1]); | |
buffer.push('" name="genericEdit">'); | |
buffer.push('<img width="18" height="18" title="Edit" alt="Edit" src="../../resources/images/pencil.png"></button>'); | |
return buffer.join(""); | |
} | |
}, | |
{ | |
"aTargets": [3], | |
"mData": null, | |
"mRender": function (data,type,row) { | |
return '<input type="checkbox"' + (row[3] ? ' checked="checked"' : '') + ' onclick="return false">'; | |
} | |
}, | |
{ | |
"aTargets": [4], | |
"mData": null, | |
"mRender": function (data,type,row) { | |
return '<input type="checkbox"' + (row[4] ? ' checked="checked"' : '') + ' onclick="return false">'; | |
} | |
} | |
]; | |
this.bSortClasses = false; | |
// Default number of rows to display | |
this.iDisplayLength = 25; | |
// Disable sort on load | |
this.aaSorting = []; | |
// Do not adjust table width | |
this.bAutoWidth = false; | |
this.bAutoHeight = false; | |
// "bPaginate":false, Turn off pagination and display all | |
// records | |
// Display number of rows options | |
this.aLengthMenu = [ [ 10, 25, 50, 100, -1 ], [ 10, 25, 50, 100, "All" ] ]; | |
// Save state | |
this.bStateSave = true; | |
// Ajax processing | |
this.bProcessing = true; | |
this.bServerSide = true; | |
this.sAjaxSource = "/b2b/api/menu/generics"; | |
this.apply = function(id) { | |
$(id).dataTable(this); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment