I have a pre grid page, where I type in input fields simple parameters like first name, surname and phone. What I would like is that those parameters will fill the filters in grid and the initial filtering would be done.
I am able to fill the filter fields but not able to do initial filtering via script. I tried using refreshFilters and filterByAll, but nothing happened. When I added alert(‘Bollocks’) and then filterByAll, everything works or when executing filterByAll via button and javascript later.
I can’t point what I am doing wrong, didn’t find anything in forum also.
var mygrid, dp;
function doOnLoad(){
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("codebase/imgs/");
mygrid.setHeader("Client ID,First Name,Surname,MobPhone,HomePh,WorkPh");
mygrid.attachHeader(" ,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");
mygrid.setColumnIds("customer_id,firstname,surname,mobile_phone,home_phone,work_phone");
mygrid.setInitWidths("75,150,150,100,100,100");
mygrid.setColAlign("left,right,right,right,right,right");
mygrid.setColTypes("ro,ed,ed,ed,ed,ed");
mygrid.setColSorting("int,str,str,str,str,str")
mygrid.setColumnColor("white,#d5f1ff,#d5f1ff,#d5f1ff,#d5f1ff,#d5f1ff")
mygrid.setColumnMinWidth(50,0);
mygrid.setSkin("dhx_skyblue");
mygrid.init();
mygrid.load("short_grid_load.php");
dp = new dataProcessor("short_grid_write.php");
dp.enableDataNames(true);
dp.init(mygrid);
<?php
if ( $_GET["firstname"] )
echo "mygrid.hdr.getElementsByTagName(\"INPUT\")[0].value = '".$_GET["firstname"]."';";
if ( $_GET["surname"] )
echo "mygrid.hdr.getElementsByTagName(\"INPUT\")[1].value = '".$_GET["surname"]."';";
if ( $_GET["phone"] )
echo "mygrid.hdr.getElementsByTagName(\"INPUT\")[2].value = '".$_GET["phone"]."';";
?>
alert('Bollocks');//working example :D
mygrid.filterByAll();
}