jqGrid or dataTable, which better? [closed]

I’ve tried both and decided to use datatables. I found it has better documentation, better community support and it was more straightforward to start and use this plugin. Basically if you have html code like this: <table> <thead> <tr>…</tr> </thead> <tbody> <tr>… </tbody> </table> (mind thead and tbody) Then yours example should generate nice datatable. …

Read more

Reload Ajax request with new parameters

You can use function as a value for ajax.data option as shown below. That way your code will be run every time the client makes request to the server and not once as with your initial code. $(‘#table1’).DataTable({ “serverSide”: true, “ajax”: { “url”: “Home/Search”, “type”: “POST”, “data”: function(d){ d.searchType = GetSearchType(); d.searchText = GetSearchText(); } …

Read more

How to add attribute in TR and TD?

Use createdRow and columns.createdCell options to define a callback function that will be called when TR and TD element are created. $(‘#example’).dataTable( { ‘createdRow’: function( row, data, dataIndex ) { $(row).attr(‘id’, ‘someID’); }, ‘columnDefs’: [ { ‘targets’: 3, ‘createdCell’: function (td, cellData, rowData, row, col) { $(td).attr(‘id’, ‘otherID’); } } ] }); See this example …

Read more

Change the default number of rows to display on one “page”

For DataTables version 1.10.5 and newer, as documented on the blog post announcing the integration of HTML5 data-* attributes, the number of rows to show per page can be specified via the source (HTML) table through the data-page-length attribute: <table data-page-length=”25″> … </table> For DataTables version 1.10 and newer, as documented at Reference > Options …

Read more

How can I get jQuery DataTables to sort on hidden value, but search on displayed value?

I believe the existing answers are deprecated due to updates to DataTables. HTML5 supports attributes that DataTables can use to easily sort columns. Specifically the data-sort attribute. (See https://datatables.net/examples/advanced_init/html5-data-attributes.html) I can easily sort tables like so: <table> <thead> <tr> <td>Name</td> <td>Age</td> </tr> </thead> <tbody> <tr> <td>John Doe</td> <td data-sort=”37″>2/1/78 (37 years old)</td> </tr> <tr> <td>Jane …

Read more

Using Jquery Datatable with AngularJs

Take a look at this: AngularJS+JQuery(datatable) FULL code: http://jsfiddle.net/zdam/7kLFU/ JQuery Datatables’s Documentation: http://www.datatables.net/ var dialogApp = angular.module(‘tableExample’, []); dialogApp.directive(‘myTable’, function() { return function(scope, element, attrs) { // apply DataTable options, use defaults if none specified by user var options = {}; if (attrs.myTable.length > 0) { options = scope.$eval(attrs.myTable); } else { options = { …

Read more

how to change language for DataTable

You have to either create a language file and then set it using : “oLanguage”: { “sUrl”: “media/language/your_file.txt” } Im not sure what server language you are using but something like this would work in PHP : “oLanguage”: { “sUrl”: “media/language/custom_lang_<?php echo $language ?>.txt” } Where language matches the file name for a specific language. …

Read more