summaryrefslogtreecommitdiffstats
path: root/codebase/Dhtmlx/Connector/KeyGridConnector.php
blob: 9862795dffa348b9905638346a2949c0a763dfaa (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="Dhtmlx\\Connector\\Data\\GridDataItem";
        if (!$data_type) $data_type="Dhtmlx\\Connector\\DataProcessor\\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");
        }
    }
};