Hey All,
I am using DataTables 1.9 and have a need to refresh my table with new aoData value on changing an option selector. The reloadTable() function shown below is placed outside the document.ready function.
1. When I use oTable.fnDraw(), the request is sent twice to the server, with aoData value of monitorAlertList & researchAlertList() in the example beow.
2. When I use oTable.fnReloadAjax() in the same line, it throws an error that it is not a function.
Please review and advise on both approaches. Thanks in advance!
I am using DataTables 1.9 and have a need to refresh my table with new aoData value on changing an option selector. The reloadTable() function shown below is placed outside the document.ready function.
1. When I use oTable.fnDraw(), the request is sent twice to the server, with aoData value of monitorAlertList & researchAlertList() in the example beow.
2. When I use oTable.fnReloadAjax() in the same line, it throws an error that it is not a function.
Please review and advise on both approaches. Thanks in advance!
var iCount; var viewList= "monitorAlertList"; oTable = $('#alertTable').dataTable( { "sScrollY": "300", "oScroller": { "loadingIndicator": true }, "sAjaxSource": "/grip/mobile/mobile", "bServerSide": true, "bDeferRender": true, "fnServerParams": function ( aoData ) { aoData.push( { "name": "requestType", "value": viewList } ); }, "sDom": "RfrtS", "bSearchable": true, "bSort": true, "bFilter": true, "sServerMethod": "GET", "bStandingRedraw" : true, "aaSorting": [[0,'desc']], "aoColumnDefs": [ { "sTitle": "Time UTC", "aTargets": [ 0 ], "sName": "time", "mData": "time" , "bVisible": true}, { "sTitle": "Type", "aTargets": [ 1 ],"sName": "type", "mData": "type" , "bVisible": true}, { "sTitle": "Severity", "aTargets": [ 2 ], "sName": "severity", "mData": "severity" , "bVisible": true}, { "sTitle": "Subject", "aTargets": [ 3 ], "sName": "subject", "mData": "subject" , "bVisible": true}, { "sTitle": "User Name", "aTargets": [ 4 ], "sName": "userName", "mData": "userName" , "bVisible": true}, { "sTitle": "Description", "aTargets": [ 5 ], "sName": "message", "mData": "message" , "bVisible": false} ], "fnDrawCallback": function ( oSettings ) { iCount = oSettings.fnRecordsTotal(); $("#iTotal").html(iCount); } } ); function reloadAlertTable() { var selectedView = $("#alertViewsList option:selected").val(); if (selectedView == 0) { viewList= "monitorAlertList"; oTable.fnSetColumnVis( 5, false ); } else if (selectedView == 1) { viewList= "researchAlertList"; oTable.fnSetColumnVis( 5, true ); } oTable.fnDraw(false); }