Hello DHMTXL-Support,
i use a dhtmlXGrid-Object with a gridConnector behind.
The whole code is very close to that in the dhtmXconnector-video-tutorial and i works fine with paging, dynamic loading and text-filters.
But i have a column, whose row-values are rewritten on the “beforeRender”-event…
$gridConnector->event->attach(“beforeRender”,“rewriteData”);
…and that special column has tinyint-values (0 or 1) on database side,
which are rewritten to “no” or “yes” in “rewriteData” to be more readable at the frontend (in the grid).
Now i would like to add a #connector_select_filter to that column:
init:
$gridConnector->event->attach(“beforeFilterOptions”,“createFilterOptions”);
the function:
function createFilterOptions($col){
switch($col){
case “myTinyIntColumn”: return array(“yes”,“no”);
…
}
}
Of course, this won’t work, because the algorithm that creates the HTML-Select-Element and its Option-Elements takes the array-values of my “createFilterOptions”-function for the value-attribute and the innerHTML of the respective HTMLOption-Elements.
Is there any way to define value-attribute and innerHTML seperately?
something like this would be nice:
function createFilterOptions($col){
switch($col){
case “myTinyIntColumn”: return array(“1”=>“yes”,“0”=>“no”);
…
}
}
…which would build:
yes
no
…and send the value-attributes to server for server-side filtering
My connector version: v.0.9 build 90226
Is there any way to define value-attribute and innerHTML seperately?
There is no such possibility in current version, it will be added as part of oncoming update ( connectors 1.0, release date - end of July )
If you need such functionality ASAP - it possible to create custom selectbox in grid , with necessary options ( through raw HTML ) and trigger server side filtering to its update - please inform if you need a sample of such customization.
Thanks for your fast answer.
I solved the problem on server side with the “beforeFilter”-event.
Here is the code for those who maybe have the same problem:
$gridConnector->event->attach(“beforeFilter”,“manageSelectFilters”);
$gridConnector->event->attach(“beforeFilterOptions”,“createFilterOptions”);
function manageSelectFilters($column,$mask){
switch($column) {
case “myTinyIntColumn”:
$where = “myTinyIntColumn=”.($mask == “yes” ? 1 : 0);
return $where;
…
}
}
function createFilterOptions($column){
switch($column){
case “myTinyIntColumn”: return array(“yes”,“no”);
…
}
}
This works fine for me.
But nice to know, that the upcoming update will contain more support for select-filters.
Good day,
peter
I still have the similar problem, It does not work at version 2.5.
Hi peter,
Could provide code of include file - I mean your code