Custom Filters with the DHTMLX Connector

My customer’s database saves has a database field called type where it stores either a T,M or L in the database.

using the $grid->set_options I was able to get the drops downs to show the completed versions of the words.

but when I use the custom_filter function to change “Type” back to “T” I have verified that it updates the $filter_by->rules array changes but when the query executes it doesn’t save the changes that I made int he custom_filter function…

any ideas on how to fix this?

[code]<?
include("…/includes/config.php");
include(“dhtmlx/grid_connector.php”);

$query = “select entry_id,name,type,active from entry”;
$mysql_server = $_SETTINGS[‘dbHost’];
$mysql_db = $_SETTINGS[‘dbName’];
$mysql_user = $_SETTINGS[‘dbUser’];
$mysql_pass = $_SETTINGS[‘dbPass’];

$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);

$grid = new GridConnector($res);
$grid->enable_log("temp.log",true);

$grid->set_options(“type”,array(“Type”=>“T”,“Material” =>“M”,“Lead Time”=>“L”));
$grid->event->attach(“beforeFilter”,“custom_filter”);
$grid->event->attach(“beforeRender”,“converttype”);
$grid->event->attach(“beforeUpdate”,“myUpdate”);
$grid->render_sql($query,“entry_id”,“name,type,active”);

function custom_filter($filter_by){
    $index = $filter_by->index("type");
    if($index == 1){
        switch ($filter_by->rules[$index]["value"]){
            case "Material":
                $filter_by->rules[$index]["value"]="M";
            break;
            case "Type":
                $filter_by->rules[$index]["value"]="T";
            break;
            case "Lead Time":
                $filter_by->rules[$index]["value"]="L";
            break;

        }
    }
return true;
}

function myUpdate($data){
$type = $data->get_value(‘type’);
switch ($type){
case “Material”:
$savetype = “M”;
break;
case “Type”:
$savetype = “T”;
break;
case “Lead Time”:
$savetype = “L”;
break;

}


        $conn->sql->query("UPDATE entry SET active='{$data->get_value('active')}' WHERE entry_id='{$data->get_id()}'");
        $data->success();
}
function converttype($data){
 $type = $data->get_value("type");
  switch ($type){
  	case "T":
    $data->set_value("type","Type");
  		break;
  	case "M":
    $data->set_value("type","Material");
  		break;
  	case "L":
    $data->set_value("type","Lead Time");
  		break;

  }
}

[/code]

Try to upgrade connector with attached one.
connector.zip (55.4 KB)

that worked Thanks!