I used beforeFilter event at ver 2.1, now the handlerfun parameter at version 2.5 is different than version 2.1. And my previous code does not work at ver 2.5. Could you provide solution according to my code below?
I would like to add customized drop list into into #connector_select_filter column, for example “yes” and “no”, here is test code. The drop list appears as “yes”, “no”, but the filter does not really work.
The client side code:
[code] mygrid.setHeader(“Catetory,Product,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan”);
mygrid.attachHeader(["#rspan",“Name”,“Code”,“Brief Desp”,“Price”,“in Stock”,“Sold”,“Enabled”,“Description”]);
mygrid.attachHeader("#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_select_filter,#connector_text_filter")
mygrid.setInitWidths("50,150,150,150,80,80,80,80,200");
mygrid.setColAlign("right,left,left,left,right,center,center,center,left");
mygrid.setColTypes("ed,ed,ed,edtxt,price,ed,co,ch,txt"); // ro is read only
mygrid.getCombo(5).put(1,"yes");
mygrid.getCombo(5).put(0,"no");
mygrid.setColSorting("int,str,str,str,int,str,str,str,str");
mygrid.setColumnColor("white,#d5f1ff,white,#d5f1ff,white,#d5f1ff,white,#d5f1ff");
mygrid.setColumnMinWidth(50,0);
mygrid.enableSmartRendering(true)
mygrid.enableMultiselect(true)
mygrid.init();
mygrid.loadXML("jb_01_basic_connector.php");
var dp = new dataProcessor("jb_01_basic_connector.php");
dp.init(mygrid);
[/code]
The sever side jb_01_basic_connector.php code:
$grid->set_options("enabled",array("yes"=>"yes","no"=>"no"));
$grid->event->attach("beforeFilter",doBeforeFilter);
$grid->render_table("ss_products","productID","categoryID,name,product_code,brief_description,Price,in_stock,items_sold,enabled,description");
function doBeforeFilter($column,$mask)
{
// It is really important to trim($column) first, otherwise case will have problem
$column = trim($column);
switch($column) {
case "enabled":
$where = "p.enabled=".($mask == "yes" ? 1 : 0);
$case = "enabled";
break;
default:
$where = $column." LIKE '%".$mask."%'";
$case = "default";
break;
}
}