Exemplo n.º 1
0
 /**
  * Ajax CTreeView backend for zones
  * @param $_GET['root']
  * @param $_GET['selected']
  */
 public function actionTreeFill()
 {
     $rootZone = $this->getRootZone($_GET['root']);
     $tree_array = $this->getChildrenAsTreeArray($rootZone, $_GET['selected']);
     echo CTreeView::saveDataAsJson($tree_array);
     exit(0);
 }
Exemplo n.º 2
0
 /**
  * Fills treeview based on the current user input.
  */
 public function run()
 {
     if (!isset($_GET['root']) || $_GET['root'] == 'source') {
         $rootId = $this->rootId;
         $showRoot = $this->showRoot;
     } else {
         $rootId = $_GET['root'];
         $showRoot = false;
     }
     $dataTree = $this->getModel()->{$this->methodName}($rootId, $showRoot);
     echo CTreeView::saveDataAsJson($dataTree);
 }
Exemplo n.º 3
0
 public function actionTreeFill()
 {
     $id = !isset($_GET['root']) ? 'source' : $_GET['root'];
     $dataTree = array();
     if ($id == 'source') {
         $root = Zone::model()->findByPk(0);
     } else {
         $root = Zone::model()->findByPk($id);
     }
     foreach ($root->children as $child) {
         $dataTree[] = array('id' => $child->zid, 'text' => CHtml::link($child->name, array('/zone/view/id/' . $child->zid)), 'collapsed' => $child->zid != 0, 'hasChildren' => true);
     }
     echo CTreeView::saveDataAsJson($dataTree);
 }
 public function actionAjaxFillTree()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         exit;
     }
     $parentId = 0;
     if (isset($_GET['root']) && $_GET['root'] !== 'source') {
         $parentId = (int) $_GET['root'];
     }
     $req = Yii::app()->db->createCommand("SELECT m1.id, m1.name AS text, m2.id IS NOT NULL AS hasChildren " . "FROM a_organization AS m1 LEFT JOIN a_organization AS m2 ON m1.id=m2.parent_id " . "WHERE m1.parent_id <=> {$parentId} " . "GROUP BY m1.id ORDER BY m1.id ASC");
     $children = $req->queryAll();
     $treedata = array();
     foreach ($children as $child) {
         $options = array('href' => Yii::app()->createUrl('aOrganization/view', array('id' => $child['id'])), 'id' => $child['id'], 'class' => 'treenode');
         $nodeText = CHtml::openTag('a', $options);
         $nodeText .= $child['text'];
         $nodeText .= CHtml::closeTag('a') . "\n";
         $child['text'] = $nodeText;
         $treedata[] = $child;
     }
     //$children = $this->createLinks($children);
     echo str_replace('"hasChildren":"0"', '"hasChildren":false', CTreeView::saveDataAsJson($treedata));
     exit;
 }
 /**
  * Fills the JS tree on an AJAX request.
  * Should receive parent node ID in $_GET['root'],
  *  with 'source' when there is no parent.
  */
 public function actionAjaxFillTree()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         exit;
     }
     $parentId = "NULL";
     if (isset($_GET['root']) && $_GET['root'] !== 'source') {
         $parentId = (int) $_GET['root'];
     }
     $req = Yii::app()->db->createCommand("SELECT m1.category_id, m1.name AS text, m2.category_id IS NOT NULL AS hasChildren " . "FROM cart_content_category AS m1 LEFT JOIN cart_content_category AS m2 ON m1.category_id=m2.parent_id " . "WHERE m1.parent_id <=> {$parentId} " . "GROUP BY m1.category_id ORDER BY m1.name ASC");
     $children = $req->queryAll();
     echo str_replace('"hasChildren":"0"', '"hasChildren":false', CTreeView::saveDataAsJson($children));
     exit;
 }
Exemplo n.º 6
0
 public function actionAjaxFillTree()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         exit;
     }
     $data = MemberService::Getmenu();
     echo str_replace('"hasChildren":"0"', '"hasChildren":true', CTreeView::saveDataAsJson($data));
     exit;
 }
Exemplo n.º 7
0
 public function actionAjaxFillTree()
 {
     $data = $this->actionGetmenu();
     echo str_replace('"hasChildren":"0"', '"hasChildren":false', CTreeView::saveDataAsJson($data));
     exit;
 }