Hello,
I am having a problem getting a beforeFilter function to work correctly. The scenario is I have a database table which has a status field with the values of Active and Inactive. When I bring the data from the table into a grid, and add a connector_select_filter to that status field it returns all results when I select “Active” because the query is doing a “like” instead of an “=” comparison. I’ve tried following the example for doing a beforeFilter to change the comparison to “=” but I can’t seem to get it to work. Can someone look at the following to see what I may be doing incorrectly? Thank you.
InitGrid
function doInitGrid(nav_officeList)
{
mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.setImagePath("includes/dhtmlx/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("Office,Client ID,Name,City,State,Zip,County,Register Date,Status");
mygrid.setInitWidths("60,65,255,152,50,53,142,150,62");
mygrid.setColAlign("center,center,left,left,center,center,left,center,left");
mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
mygrid.setColSorting("connector,connector,connector,connector,connector,connector,connector,connector,connector");
mygrid.attachHeader("#connector_select_filter,#text_search,#connector_text_filter,#connector_text_filter,#connector_select_filter,#connector_text_filter,#connector_select_filter,,#connector_select_filter");
mygrid.setSkin("modern");
mygrid.init();
mygrid.enableSmartRendering(true);
mygrid.loadXML("includes/php/db_dhtmlx_connector.php?nav_officeList=" + nav_officeList);
}
Custom Filter
[code]function custom_filter($filter_by)
{
$index = $filter_by->index(“ClientStatus”);
if ($index!==false) $filter_by->rules[$index][“operation”] = “=”;
}
$grid->event->attach(“beforeFilter”,“custom_filter”);
$grid->render_sql(“SELECT O.OfficeCode, C.* FROM Client C, core.Offices O WHERE (O.OfficeNumber = C.CompNo) AND (C.CompNo IN (”.$_REQUEST[‘nav_officeList’]."))",“C.ClientKey”,“OfficeCode, ClientKey, Company, City, State, Zip, County, RegDate, ClientStatus”);
?>
[/code]
Query From Log
SELECT O.OfficeCode, C.* FROM Client C, core.Offices O WHERE (O.OfficeNumber = C.CompNo) AND (C.CompNo IN (1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17)) AND ClientStatus LIKE '%Active%'