diff options
author | dmitry-radyno <dmitry.radyno@gmail.com> | 2013-05-30 16:45:05 +0200 |
---|---|---|
committer | dmitry-radyno <dmitry.radyno@gmail.com> | 2013-05-30 16:45:05 +0200 |
commit | eb0386dd25a066532be6549a342e61d80c438477 (patch) | |
tree | 827da2ba021dc9472773698c791173b2c110bfec /codebase/data_connector.php | |
parent | a195de87f3f78fee4da45e765fe5d0dac7b2455f (diff) | |
download | connector-php-eb0386dd25a066532be6549a342e61d80c438477.zip connector-php-eb0386dd25a066532be6549a342e61d80c438477.tar.gz connector-php-eb0386dd25a066532be6549a342e61d80c438477.tar.bz2 |
collections in JSONTreeDataConnector
Diffstat (limited to 'codebase/data_connector.php')
-rw-r--r-- | codebase/data_connector.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/codebase/data_connector.php b/codebase/data_connector.php index 8de6025..cf52597 100644 --- a/codebase/data_connector.php +++ b/codebase/data_connector.php @@ -415,6 +415,11 @@ class JSONTreeDataConnector extends TreeDataConnector{ $data = array(); $data["parent"] = $this->request->get_relation(); $data["data"] = $result; + + $this->fill_collections(); + if (!empty($this->options)) + $data["collections"] = $this->options; + $data = json_encode($data); // return as string @@ -427,6 +432,42 @@ class JSONTreeDataConnector extends TreeDataConnector{ $out->output("", true, $this->encoding); } + /*! assign options collection to the column + + @param name + name of the column + @param options + array or connector object + */ + public function set_options($name,$options){ + if (is_array($options)){ + $str=array(); + foreach($options as $k => $v) + $str[]=Array("id"=>$this->xmlentities($k), "value"=>$this->xmlentities($v));//'{"id":"'.$this->xmlentities($k).'", "value":"'.$this->xmlentities($v).'"}'; + $options=$str; + } + $this->options[$name]=$options; + } + + /*! generates xml description for options collections + + @param list + comma separated list of column names, for which options need to be generated + */ + protected function fill_collections($list=""){ + $options = array(); + foreach ($this->options as $k=>$v) { + $name = $k; + if (!is_array($this->options[$name])) + $option=$this->options[$name]->render(); + else + $option=$this->options[$name]; + $options[$name] = $option; + } + $this->options = $options; + $this->extra_output .= "'collections':".json_encode($options); + } + } |