How to make datatable row or cell clickable?

To activate click on cell you must use a delegated event handler – this will work on any dataTable : $(‘.dataTable’).on(‘click’, ‘tbody td’, function() { //get textContent of the TD console.log(‘TD cell textContent : ‘, this.textContent) //get the value of the TD using the API console.log(‘value by API : ‘, table.cell({ row: this.parentNode.rowIndex, column : … Read more

How to implement hierarchical multilevel datatable in javaScript?

The simplest way I can think of accomplishing this with vanilla Javascript would be a modified depth first traversal of an object: function renderJSON(json) { const wrapper = document.createElement(‘div’); const stack = [{ node: json, name: ‘root’, parentEl: wrapper }]; while (stack.length > 0) { let current = stack.pop(); let currentObj = current.node; let currentParentEl … Read more

Implement JQuery Datatable in ASP.NET GridView

These few lines are all you need to get it working. You don’t need the prerender event. Just bind in Page_Load in the IsPostBack check. I did add a RowDataBound event to the GridView to add the <thead> and <tbody> sections programatically rather than with jQuery. <script type=”text/javascript” src=”https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js”></script> <link type=”text/css” rel=”stylesheet” href=”https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css” /> <asp:GridView … Read more

How can I remove the search bar and footer added by the jQuery DataTables plugin?

For DataTables >=1.10, use: $(‘table’).dataTable({searching: false, paging: false, info: false}); If you still want to be able to use the .search() function of this plugin, you will need to hide the search bar’s html with the dom setting: $(‘table’).dataTable({dom: ‘lrt’}); The defaults are lfrtip or <“H”lfr>t<“F”ip> (when jQueryUI is true), f char represents the filter … Read more

jQuery plugin DataTables: How to highlight the current search text?

I would have to suggest the highlight plugin 🙂 I’m using this in about the same scenario right now, it’s given me no issues thus far. The usage is pretty simple: $(“#myTable”).highlight($(“#searchBox”).val()); Just put the highlight CSS class in your stylesheet styles like you want and that’s it: .highlight { background-color: yellow }