- });
- columns = columns.substring(0, columns.length - 1 );
- sortColumn = sortColumn.substring(0, sortColumn.length - 1 );
- eval('sortColumn =[' + sortColumn + ']');
- eval('columns =[' + columns + ']');
-
- var currTable = cj(tabId);
- if (currTable) {
- // contains the dataTables master records
- var s = cj(document).dataTableSettings;
- if (s != 'undefined') {
- var len = s.length;
- for (var i=0; i < len; i++) {
- // if already exists, remove from the array
- if (s[i].sInstance = tabId) {
- s.splice(i,1);
- }
- }
- }
- }
-
- var noRecordFoundMsg = {/literal}'{ts escape="js"}There are no records.{/ts}'{literal};
-
- oTable = null;
- if ( useAjax ) {
- oTable = cj(tabId).dataTable({
- "bFilter" : false,
- "bAutoWidth" : false,
- "aaSorting" : sortColumn,
- "aoColumns" : columns,
- "bProcessing": true,
- "bJQueryUI" : true,
- "asStripClasses" : [ "odd-row", "even-row" ],
- "sPaginationType": "full_numbers",
- "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
- "bServerSide": true,
- "sAjaxSource": sourceUrl,
- "oLanguage":{"sEmptyTable" : noRecordFoundMsg,
- "sZeroRecords" : noRecordFoundMsg },
-
- {/literal}{if !empty($callBack)}{literal}
- "fnDrawCallback": function() { checkSelected(); },
- {/literal}{/if}{literal}
-
- "fnServerData": function ( sSource, aoData, fnCallback ) {
- cj.ajax( {
- "dataType": 'json',
- "type": "POST",
- "url": sSource,
- "data": aoData,
- "success": fnCallback
- });
- }
- });
- } else {
- oTable = cj(tabId).dataTable({
- "aaSorting" : sortColumn,
- "bPaginate" : false,
- "bLengthChange": true,
- "bFilter" : false,
- "bInfo" : false,
- "asStripClasses" : [ "odd-row", "even-row" ],
- "bAutoWidth" : false,
- "aoColumns" : columns,
- "bSort" : sortEnabled,
- "oLanguage":{"sEmptyTable" : noRecordFoundMsg,
- "sZeroRecords" : noRecordFoundMsg }
- });
- }
- var object;
-
- if ( !useAjax ) {
- cj('a.action-item').click( function(){
- object = cj(this);
- cj('table.display').one( 'mouseover', function() {
- var nNodes = oTable.fnGetNodes( );
- var tdSelected = cj(object).closest('td');
- var closestEle = cj(object).closest('tr').attr('id');
- cj.each( nNodes, function(i,n) {
- //operation on selected row element.
- if ( closestEle == n.id ){
- var col = 0;
- cj('tr#' + closestEle + ' td:not(.hiddenElement)').each( function() {
- if ( tdSelected.get(0) !== cj(this).get(0) ){
- oTable.fnUpdate( cj(this).html() , i, col );
- }
- col++;
- });
- }
+ });
+ // Fixme: this could be done without eval
+ columns = columns.substring(0, columns.length - 1 );
+ sortColumn = sortColumn.substring(0, sortColumn.length - 1 );
+ eval('sortColumn =[' + sortColumn + ']');
+ eval('columns =[' + columns + ']');
+
+ var noRecordFoundMsg = {/literal}'{ts escape="js"}None found.{/ts}'{literal};
+
+ var oTable;
+ if ( useAjax ) {
+ oTable = $(tabId).dataTable({
+ "bFilter": false,
+ "bAutoWidth": false,
+ "aaSorting": sortColumn,
+ "aoColumns": columns,
+ "bProcessing": true,
+ "bJQueryUI": true,
+ "asStripClasses": [ "odd-row", "even-row" ],
+ "sPaginationType": "full_numbers",
+ "sDom": '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
+ "bServerSide": true,
+ "sAjaxSource": sourceUrl,
+ "oLanguage":{
+ "sEmptyTable": noRecordFoundMsg,
+ "sZeroRecords": noRecordFoundMsg
+ },
+ "fnServerData": function ( sSource, aoData, fnCallback ) {
+ $.ajax( {
+ "dataType": 'json',
+ "type": "POST",
+ "url": sSource,
+ "data": aoData,
+ "success": fnCallback