Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by peter on Jul 06, 2009 14:53
open dhtmlx forum
GridConnector and #connector_select_filter

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:

<select style="width: 90%; font-size: 8pt; font-family: Tahoma;">
<option value="1">yes</option>
<option value="0">no</option>
</select>

...and send the value-attributes to server for server-side filtering


My connector version: v.0.9 build 90226
Answer posted by Support on Jul 07, 2009 02:44
>>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. 
Answer posted by peter on Jul 07, 2009 07:41
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