Filtering with check boxes for serverside interactions
Filtering with check boxes for serverside interactions
Aloha!
Let's say we take this example http://www.datatables.net/examples/server_side/server_side.html
as a base for serverside interactions.
How can we filter data with checkboxes? So basically I want to have a with few checkboxes and by using select function I want to be able to select 1 or more options for each column. Example below only shows how to do it for 1 parameter.
I did few other examples for Ajax, but I still couldn't figure out my question with checkboxes for filtering on serverside. This example as close as it gets http://www.datatables.net/examples/api/multi_filter_select.html
Thank you for all your help in advance =)
Awesome script!
Let's say we take this example http://www.datatables.net/examples/server_side/server_side.html
as a base for serverside interactions.
How can we filter data with checkboxes? So basically I want to have a with few checkboxes and by using select function I want to be able to select 1 or more options for each column. Example below only shows how to do it for 1 parameter.
I did few other examples for Ajax, but I still couldn't figure out my question with checkboxes for filtering on serverside. This example as close as it gets http://www.datatables.net/examples/api/multi_filter_select.html
Thank you for all your help in advance =)
Awesome script!
This discussion has been closed.
Replies
[code]
$('#filterimage'> img').bind('click',function(e){
e.stopPropagation();
fnCreatePopup( oTable.fnGetColumnData(n),vendorId,1 );
/*where vendorId is column name and 1 is column no and filterimage is div id having image,and on click of that image i am calling a popup which is having checkboxes and some buttons.*/
[/code]
definition of fnGetColumnData is...
[code]
var container=""
jQuery.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
// check that we have a column id
if ( typeof iColumn == "undefined" ) return new Array();
// by default we only wany unique data
if ( typeof bUnique == "undefined" ) bUnique = true;
// by default we do want to only look at filtered data
if ( typeof bFiltered == "undefined" ) bFiltered = true;
// by default we do not wany to include empty values
if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true;
// list of rows which we're going to loop through
var aiRows;
// use only filtered rows
if (bFiltered == true) aiRows = oSettings.aiDisplay;
// use all rows
else aiRows = oSettings.aiDisplayMaster; // all row numbers
// set up data array
var asResultData = new Array();
for (var i=0,c=aiRows.length; i -1) continue;
// else push the value onto the result data array
else asResultData.push(sValue);
}
return asResultData;
};
//And fnCreatepopUp is
function fnCreatePopup( aData, str,columnNumber )
{
jQuery("#"+str).remove();
var Id="'"+str+"'"
var r=''+str+'', i, iLen=aData.length;
for ( i=0 ; i0){
oTable.fnFilter([container],iColumn,false);//filtering the table with value of checked checkboxes
//i think here you can write your own filtering logic with 1 or more parameters
}
else{
oTable.fnFilter('',iColumn,false);
}
container = ""
SaveState(str);
jQuery('#'+str).hide();
}
[/code]
check out this code.......may be it's work for you guys...
let me know if you stuck any where....
waiting for your replies...
Thanks,
Vivek
[code]/* Individual column filtering */
/*got to figure this bit out - using example of sSearch_2 with multpiple values in string*/
foreach ( $_GET['sSearch_2'] as $keyname => $value)
{
$searcharray .= ' '.$value.',';
}
for ( $i=0 ; $i