开发者

DataTables, Ajax Pipelining

I'm using DataTables with pipelining. I works great except when I tried to enter an extra column to hold "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 clientside:

    $(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",
       sAddHttp开发者_C百科Method: "POST",
       sDeleteURL: "DeleteData.php",
       sDeleteHttpMethod: "POST",
       aoColumns: [ { } , { } , null ]
    });
  });

So, why isn't this working?


Just done this exact same thing myself. I like to configure all my columns using aoColumnDefs, as you can add multiple configuration options for columns in one go.

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

Note that aTargets is an array of column indexes you want to apply those settings to. So if you were to add more link columns (e.g. a Delete link), you can turn off sorting on those without rewriting the column definition every time.

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

And, as I was saying, you can add further configuration options for columns in this 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'}
]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜