summaryrefslogtreecommitdiffstats
path: root/codebase/Dhtmlx/Connector/KeyGridConnector.php
blob: 001cae9a3a1d326e30c446f5e28d9a88499fad86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace Dhtmlx\Connector;

class KeyGridConnector extends GridConnector {
    public function __construct($res,$type=false,$item_type=false,$data_type=false){
        if (!$item_type) $item_type="GridDataItem";
        if (!$data_type) $data_type="KeyGridDataProcessor";
        parent::__construct($res,$type,$item_type,$data_type);

        $this->event->attach("beforeProcessing",array($this,"before_check_key"));
        $this->event->attach("afterProcessing",array($this,"after_check_key"));
    }

    public function before_check_key($action){
        if ($action->get_value($this->config->id["name"])=="")
            $action->error();
    }
    public function after_check_key($action){
        if ($action->get_status()=="inserted" || $action->get_status()=="updated"){
            $action->success($action->get_value($this->config->id["name"]));
            $action->set_status("inserted");
        }
    }
};