DataTables, Ajax Pipelining

I am using DataTables with pipelining . I work just fine, except when I tried to enter an extra column to hold the edit links. See this table.

Here is a snippet of server_processing.php showing the columns:

/* Array of database columns which should be read and sent back to DataTables. * Use a space where you want to insert a * non-database field (for example a counter or static image) */ $aColumns = array( 'user','email', ); 

And here is the client:

  $(document).ready( function (){ $('#example').dataTable({ "bProcessing": true, "bServerSide": true, "sAjaxSource": "scripts/server_processing.php", "fnServerData": fnDataTablesPipeline, aoColumns: [null, null, {"bSortable": false}] }).makeEditable({ sUpdateURL: "UpdateData.php", sAddURL: "AddData.php", sAddHttpMethod: "POST", sDeleteURL: "DeleteData.php", sDeleteHttpMethod: "POST", aoColumns: [ { } , { } , null ] }); }); 

So why is this not working?

+6
source share
1 answer

Just did the same thing myself. I like to customize all my columns with aoColumnDefs , since you can add several configuration options for the columns at a time.

 // Disable sorting on the 3rd column 'aoColumnDefs': [{'aTargets': [2], 'bSortable': false}] 

Note that aTargets is an array of column indices to which you want to apply these parameters. Therefore, if you need to add additional column links (for example, the "Delete" link), you can turn off sorting for those that do not change the definition of the column each time.

 // Disable sorting on the 3rd and 4th column 'aoColumnDefs': [{'aTargets': [2,3], 'bSortable': false}] 

And, as I said, you can add additional configuration options for the columns in the same array:

 // Disable sorting on the 3rd and 4th column and sort 1st column by string 'aoColumnDefs': [ {'aTargets': [2,3], 'bSortable': false} {'aTargets': [0], 'sType': 'string'} ] 
+3
source

Source: https://habr.com/ru/post/892611/


All Articles