Search
23433 results 3031-3040
Forum
- 30th Sep 2014Custom sorting where some columns take priorityI need advice on implementing custom sorting. I am developing a message inbox module (similar to Outlook). Two of the message properties are boolean isPinned & isLocked. isPinned means the user wants the msg pinned to the top of grid. isLocked means it is pinned (isLocked = isPinned = true) by the organization which should display above user-pinned messages. The tricky part is that when a user clicks on the From/Sender/Date column headers for sorting, the sort algorithm needs to ALWAYS sort isLocked to the top, followed by isPinned, followed by whatever column the user clicked on. I call the following Knockout function to initially sort the data (static data right now but eventually via Web API). I just need to figure out how to tweak column sorting to use something similar. Note: grid data is not editable, though the user can toggle pinned status (but not locked) and can click a trash icon to set isDeleted = true (it will be moved to the Trash folder). self.sortMessageHeaders = function () { self.messageHeaders.sort(function (left, right) { // original sorting algorithm--compact version of the if..blocks below //return left.isLocked() != right.isLocked() ? (left.isLocked() < right.isLocked() ? 1 : -1) : left.isPinned() != right.isPinned() ? (left.isPinned() < right.isPinned() ? 1 : -1) : left.dateSent() < right.dateSent() ? 1 : 0; // sort by locked status if they are different if (left.isLocked() != right.isLocked()) { return (left.isLocked() < right.isLocked() ? 1 : -1); } // otherwise, sort by pinned status if they are different if (left.isPinned() != right.isPinned()) { return (left.isPinned() < right.isPinned() ? 1 : -1); } // as a last resort, sort by date/time sent return (left.dateSent() < right.dateSent() ? 1 : -1); }); }; Thanks for your time and attention.
- 17th Sep 2014Don't allow reorder on certain columnsIs there an option in columnDefs to not allow the column to be reordered.
- 17th Sep 2014Columns Order Direction can be accessed from data function?Hello, I am using datatables 1.10 and I have defined a data function in the ajax property of my datatables options as follow: "ajax": { url: AllMxEnvironments.Config.AjaxSource, data: function (d) { } } The problem is in the property d I can access all my changes in the datatable except for sorted column index and OrderDirection. Is there a way to access the ColumnOrder and OrderDirection properties of each column within this function? In case I can't can you please tell me how to get the object in the preDrawCallback or on the draw event of the table? Thanks, Jhonny.
- 31st Aug 2014One columns with static content while the others are filled with Ajax.Hi all, My question is simple enough. I have a datatable currently being populated by an Ajax call, aoColumns, and mDataProp for the fields. I want to add a column that is simply " for all rows. How do I incorporate static content into a dynamically filled table? Thanks!
- 22nd Aug 2014Not able to filter and sort columns using Json string from ajax source on ASPX pageHere's my java script: $(document).ready(function () { var table; $("thead input").keyup(function () { /* Filter on the column (the index) of this element */ table.fnFilter(this.value, table.oApi._fnVisibleToColumnIndex( table.fnSettings(), $("thead input").index(this))); }); $("thead input").each(function (i) { this.initVal = this.value; }); $("thead input").focus(function () { if (this.className == "search_init") { this.className = ""; this.value = ""; } }); $("thead input").blur(function (i) { if (this.value == "") { this.className = "search_init"; this.value = this.initVal; } }); table = $('#gridTable').dataTable({ "bPaginate": true, "bProcessing": true, "bServerSide": true, "bSortCellsTop": true, "sDom": 'T<"clear">Rlfrtip', "oLanguage": { "sSearch": "Pesquisar no resultado geral:" }, "contentType": "application/json; charset=utf-8", "sAjaxSource": "CustomerService.asmx/GetList", "fnServerData": function (sSource, aoData, fnCallback) { $.ajax({ "dataType": 'json', "contentType": "application/json; charset=utf-8", "type": "GET", "url": sSource, "data": aoData, "success": function (msg) { var json = jQuery.parseJSON(msg.d); fnCallback(json); $("#gridTable").show(); } }); } }); });
- 11th Aug 2014How to implement checkbox filter using datatable to all the columnsIm trying to have a dropdown list with checkboxes of unique data to each column using datatable and also column filter plugin. But Im getting it only to the first column . Please find the code here http://jsfiddle.net/alamelus/1wbgwhao/ Kindly help me.. Im not able to find a proper solution for this anywhere... Thanks in advance
- 25th Jul 2014Is it possible to apply DataTable to Nested tables ? Like some of the columns contain inner tableMy requirement is In some row there will be an table and for some of the rows there is now table just data, in this case i need to apply datatable to this, I already tried applying datatable but all inner tables showing first and next the rows which are not having inner tables are showing, But my table structure is changing , that should not be done Please look at below screenshot how my data will look like http://www.evernote.com/shard/s390/sh/28cc5ec4-c3c0-47c0-9766-42786ba6d890/121ea11fd3749697b154dabff25c9ba0 and http://live.datatables.net/cayepib/2/edit
- 8th Jul 2014Using bHideGroupingColumn how to replace the hidden columns with a letter or symbol such as "-"After hiding a column.. or instead of hiding the column how do you replace repetitious data with an symbol such as "-"
- 15th Jun 2014Columns Render Error on DisplayI am using dataTables with Ajax. I have a column that contains an 'action_date' and in some cases, this will be null. I am formatting this column using moment.js for display. I get the 'datatables.net/tn/4' error. If you clear the dialog, the table will draw correctly, but I can't seem to get the error to stop. I added the default_content value as suggested on the error page. I have also tried removing the null comparison. Neither of these work. I have recreated my issue in the following bin: http://live.datatables.net/tedulub/1/edit The Ajax data in the bin has a date that I was able to use. Obviously, I can't make some of them null, but I left the null logic in my function anyway. I also included my real function in comment, just for reference. I'm sure I'm missing something obvious, but staring at it for hours isn't working. Thank you for your help.
- 10th Jun 2014How to retrieve current order of columns after reorder?This seems like it should be simple, so I must be overlooking something. I'm trying to retrieve the current column ordering so that I can save it on the server. Is this not possible with the ColReorder plugin? or even DataTables.api ?