Search
23433 results 2951-2960
Forum
- 23rd Oct 2009Added data does not match columnsHi kellyjandrews, I presume you are using fnAddData somewhere? Could you possible include that code - or ideally a link showing the problem? Thanks, Allan
- 26th May 2009Sorting by something other than columns...Hi rickblalock, I'm not sure I quite get the question - isn't the th sorting vertical (i.e. column)? Although this form doesn't allow files to be attached, perhaps you could put your screenshot up on the web somewhere and post a link so we can see what you are looking for? Also, have you had a look at the fnSort() API function, can this help with what you are looking for ( http://datatables.net/api#fnSort )? Allan
- 9th May 2009No sorting for ordinal columnsThis isn't something which is built into DataTables, but could be done through a callback function. What to do is to use fnDrawCallback() ( http://datatables.net/usage#fnDrawCallback ) to renumber your ordinal column on each draw. To optimise this it would be good to check the value of aaSorting from the last draw against the current aaSorting value to see if the sorting has changed. In this way you can update the ordinal only if needed. Hope this helps! If you make any head way with this code, perhaps you could post it here? I'm sure others would find it useful as well! Regards, Allan
- 8th Aug 2021Multiple columns of bit data typeHello, I have multiple fields in Editor, which all have a data type of bit or Booleans: editor_0 = new $.fn.dataTable.Editor({ ajax: { url: "/api/dataSetComplete", }, table: "#dsAll", fields: [{ label: "Median", name: "A_Run_Proj_Input_Data.MedianIncluded", type: "select", options: { "Yes": true, "No": false } }, { label: "Shoulder", name: "A_Run_Proj_Input_Data.ShldIncluded", type: "select", options: { "Yes": true, "No": false } }, { label: "Ramp", name: "A_Run_Proj_Input_Data.RampIncluded", type: "select", options: { "Yes": true, "No": false } } ] }); It seems that these fields interfere each other by allowing only one to be 'true' at the same time. If one is chosen to be true the other fields two will become false automatically. Could anyone can explain why? Thank you, YL
- 5th Apr 2021Columns Filtering when column is array typeSure there is better way to do, but this work api.columns( FilterColumnList ).every( function () { var column = this; var select = $('<select><option value=""></option></select>') .appendTo( $(column.footer()).empty() ) .on( 'change', function () { var val = $.fn.dataTable.util.escapeRegex($(this).val()); column .search( val ? '^'+val+'$' : '', true, false ) .draw(); } ); if ( $( column.header() ).hasClass( 'dt-render' ) ) { var cells = api.cells( null, this ); if ( Array.isArray( cells.data()[ 0 ] ) ){ // type array var sArr = cells.data(), dArr = []; // unique set of datas for ( var z=0; z < sArr.length; z++ ){ sArr[ z ].forEach( function( e ) { e = Object.values( e ); if( $.inArray( e[ 0 ], dArr ) === -1 ) dArr.push( e[ 0 ] ); }); } dArr.sort(function(a, b){ if (isNaN( a )) { var aa = a.toLowerCase(); var bb = b.toLowerCase(); } else { var aa = Number( a ); var bb = Number( b ); } if ( aa < bb ) { return -1; } else if ( aa > bb ) { return 1; } return 0; }) dArr.forEach( function ( d, j ) { var t = '<option '; if ( (d) ){ if (savedColumnsFilters){ if (savedColumnsFilters[column[0][0]].search.search.replace(/\\/g,"") == '^'+d+'$'){ t += "selected='selected' "; } } select.append( t + 'value="'+d+'">'+d+'</option>' ); } } ); } else { cells.render('display').unique().sort().each( function ( d, j ) { var t = '<option '; if ( (d) ){ if (savedColumnsFilters){ if (savedColumnsFilters[column[0][0]].search.search.replace(/\\/g,"") == '^'+d+'$'){ t += "selected='selected' "; } } select.append( t + 'value="'+d+'">'+d+'</option>' ); } } ); }; } else { column.data().unique().sort().each( function ( d, j ) { var t = '<option '; if ( (d) ){ if (savedColumnsFilters){ if (savedColumnsFilters[column[0][0]].search.search.replace(/\\/g,"") == '^'+d+'$'){ t += "selected='selected' "; } } select.append( t + 'value="'+d+'">'+d+'</option>' ); } }); } });
- 3rd Jan 2020How to fetch values from database only for particular columnsIn the below screenshot , I want to fetch values for column 2 and column 4 values to be fetched from database. The column 1 and Column 3 has to be hardcoded. How can I do this?
- 20th Jun 2019Can I generate a calendar/agenda whith dynamic columns with editor ?I am trying to use datatable to create an agenda. In this agenda each column match a month. Is it possible to do that with datatable ? have you got some examples ?
- 27th Mar 2018With Fixed columns and scrollbar I get an overlapping header.I see this issue was listed earlier in the following example: https://datatables.net/forums/discussion/comment/101190/#Comment_101190 The screenshot above is from the live example here. https://jsfiddle.net/65jLxjm2/5/ I am not sure if a response resolved this issue: Best Regards, Sumit.
- 16th Mar 2018How to get get multiple columns data of datatables in one array?for example for getting data from one column code is var table = $('#example').DataTable(); var plainArray = table .column( 0 ) .data() .toArray(); But I want column 0 and column 3 in same array , how to get that ?
- 23rd Feb 2018ColReorder sum of columnsIn drawCallback i need to calc values in column. I have made it. It works fine. drawCallback: function(row, data, start, end, display) { var cols = [0, 3, 4, 8]; // cols indexes var api = this.api(), data; var z = document.querySelectorAll('.calc-numbers'); Array.prototype.forEach.call(z, function(el, i) { z[i].innerHTML = new BigNumber(api.column(cols[i], {filter: 'applied'}).data().sum().toFixed(0)).toFormat(0); }); } ` But when i use an extension "ColReorder", after reorder column it doesnt work, becase cols indexes are changing. How to fix it? Thanks for help