ColumnFilter, Dynamic Select items?
ColumnFilter, Dynamic Select items?
I'm using DataTables with the ColumnFilter Plugin and server-side processing. I am curious how I would go about adding dynamic values based on the column data for the "select" type. I'm fairly new to DataTables, so please forgive me if I've missed something completely obvious.
Here's my code
[code]
$(document).ready(function()
{
var oTable = $('#data_table').dataTable ({
'bAutoWidth' : false,
'bProcessing' : true,
'bServerSide' : true,
"bStateSave" : false,
"sDom": 'lfT<"clear">rptip',
'sPaginationType': 'full_numbers',
"iDisplayLength": 50,
"aLengthMenu": [[15, 25, 50, 100, 100000000], [15, 25, 50, 100, "All"]],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,10 ] } ],
"aaSorting": [[ 1, "desc" ]],
'sAjaxSource' : '<?php echo base_url();?>object/listener',
'fnServerData': function(sSource, aoData, fnCallback) {
$.ajax ({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
}
}).columnFilter(
{
aoColumns: [
null,
{type: "number"},
{type: "text", bRegex: true, bSmart: true},
{type: "text", bRegex: true, bSmart: true},
{type: "number"},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
null
]
}
);
});
[/code]
the table
[code]
ID
Name
Serial
Tag
Type
Model
Company
Location
Status
ID
Name
Serial
Tag
Type
Model
Company
Location
Status
[/code]
Here's my code
[code]
$(document).ready(function()
{
var oTable = $('#data_table').dataTable ({
'bAutoWidth' : false,
'bProcessing' : true,
'bServerSide' : true,
"bStateSave" : false,
"sDom": 'lfT<"clear">rptip',
'sPaginationType': 'full_numbers',
"iDisplayLength": 50,
"aLengthMenu": [[15, 25, 50, 100, 100000000], [15, 25, 50, 100, "All"]],
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 0,10 ] } ],
"aaSorting": [[ 1, "desc" ]],
'sAjaxSource' : '<?php echo base_url();?>object/listener',
'fnServerData': function(sSource, aoData, fnCallback) {
$.ajax ({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
}
}).columnFilter(
{
aoColumns: [
null,
{type: "number"},
{type: "text", bRegex: true, bSmart: true},
{type: "text", bRegex: true, bSmart: true},
{type: "number"},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
{type: "select", values: [ 'A', 'B', 'C' ]},
null
]
}
);
});
[/code]
the table
[code]
ID
Name
Serial
Tag
Type
Model
Company
Location
Status
ID
Name
Serial
Tag
Type
Model
Company
Location
Status
[/code]
This discussion has been closed.
Replies