Hi guys, I’ve pasted my code below and I’m stuck getting the combo filter default value set. Can someone assist me with doing so or advise if I’m missing something. Thanks for your help.
The code I was given is below, but I’m not to sure where to put it or how to call it - I want my country value for example to default to Australia.
mygrid.load(ulr,function(){
mygrid.getFilterElement(6).value=“Australia”
mygrid.filterByAll();
})
The code which you are using is correct and will work correctly for normal select filters.
The problem is that connector 0.9 requires additional server side code to fill the select-boxes with options ( currently your code correctly sets value, but it doesn’t change anything - because selectboxes has no options defined )
In next few weeks, updated version of dhtmlxConnector will be released, which will allow more easy way of select filter usage ( it will not require any additional code and will fill select filters automatically - so your current code will work with it correctly )
If you need update ASAP - you can try to use attached codebase instead of original one
dhtmlxConnector_php.zip (105 KB)
If you are using data base from the dhtmlxConnector_php\samples\ folder, your code should looks like that:
mygrid.load(ulr,function(){
mygrid.getFilterElement(6).value="Australia "
mygrid.filterByAll();
})
Thanks for the attached file, I tried this codebase and I got ‘Empty Stack’ Error before making any changes to my working grid., obviously not 100% compatible. Any tips on getting this to work or should I wait? The table is used on a web page and I’m keen to launch it soon so wondering how long before final realease of what you mention is available.
I’m still not 100% sure on my code if the above is correct where do I place it.? Is it placed in the function doInitGrid area? like below? I could find references to this but I searched my PC for examples but nothing could be found. I looked in my samples folder but I must have deleted the sample because I can’t find one.
>>obviously not 100% compatible
Technically it must be 100% compatible for the grid. We will prepare and send working sample by email.
>>I’m still not 100% sure on my code
Instead of using
mygrid.loadXML(mygridQString);
mygrid.load(ulr,function(){
mygrid.getFilterElement(6).value=“Australia”
mygrid.filterByAll();
})
you need to use
mygrid.load(mygridQString,function(){
mygrid.getFilterElement(6).value=“Australia”
mygrid.filterByAll();
})
Thank you for that, the code executes fine now, obviously the default isn’t working with the old codebase but that’s a good start.
FYI The error I get when trying to use the new codebase is below.
<www.example.com>
Fatal error: Uncaught exception ‘Exception’ with message ‘Source of data can’t be empty’ in /home/content/l/u/k/luke/html/dhtmlxGrid/dhtmlxConnector_php/codebase/db_common.php:95
Stack trace:
#0 /home/content/l/u/k/luke/html/dhtmlxGrid/dhtmlxConnector_php/codebase/db_common.php(119): DataRequestConfig->set_source(’’)
#1 /home/content/l/u/k/luke/html/dhtmlxGrid/dhtmlxConnector_php/codebase/base_connector.php(248): DataRequestConfig->parse_sql(‘SELECT table.val1…’)
#2 /home/content/l/u/k/luke/html/getgridrecords.php(97): Connector->render_sql(‘SELECT table.val1…’, ‘val2’, ‘val3,val4…’)
#3 {main}
thrown in /home/content/l/u/k/lukehepburn/html/dhtmlxGrid/dhtmlxConnector_php/codebase/db_common.php on line 95
If it possible - please send full SQL text, used inside render_sql, to support@dhtmlx.com; it seems that code was not able to locate table name, used inside your SQL code.