/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdNodeGroupAttr::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'ngroup_id' => $this->ngroup_id, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'attr_name', $this->attr_name])->andFilterWhere(['like', 'attr_value', $this->attr_value])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
 /**
  * Displays a single DcmdNodeGroup model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $searchModel = new DcmdNodeSearch();
     $searchModel->ngroup_id = $id;
     $params = Yii::$app->request->queryParams;
     $params["DcmdNodeSearch"]["ngroup_id"] = $id;
     $params["DcmdNodeSearch"]["rack"] = "";
     $dataProvider = $searchModel->search($params);
     $show_div = "dcmd-node-group";
     if (array_key_exists('show_div', $params)) {
         $show_div = $params['show_div'];
     }
     if (array_key_exists("DcmdNodeSearch", Yii::$app->request->queryParams)) {
         $show_div = 'dcmd-node';
     }
     ///获取属性
     $self_attr = DcmdNodeGroupAttr::find()->andWhere(['ngroup_id' => $id])->asArray()->all();
     $def_attr = DcmdNodeGroupAttrDef::find()->asArray()->all();
     $attr_str = '<div id="w1" class="grid-view">
       <table class="table table-striped table-bordered"><thead>
       <tr><th>属性名</th><th>值</th><th>操作</th></tr>
       </thead><tbody>';
     $attr = array();
     foreach ($self_attr as $item) {
         $attr_str .= '<tr><td>' . $item['attr_name'] . '</td><td>' . $item['attr_value'] . '</td><td><a href="/ducter/index.php?r=dcmd-node-group-attr/update&id=' . $item['id'] . '&ngroup_id=' . $id . '">修改</a></td></tr>';
         $attr[$item['attr_name']] = $item['attr_name'];
     }
     foreach ($def_attr as $item) {
         if (array_key_exists($item['attr_name'], $attr)) {
             continue;
         }
         $attr_str .= '<tr><td>' . $item['attr_name'] . '</td><td>' . $item['def_value'] . '</td><td><a href="/ducter/index.php?r=dcmd-node-group-attr/update&id=0&attr_id=' . $item['attr_id'] . '&ngroup_id=' . $id . '">修改</a></td></tr>';
     }
     $attr_str .= "</tbody></table></div>";
     return $this->render('view', ['model' => $this->findModel($id), 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'attr_str' => $attr_str, 'ngroup_id' => $id, 'show_div' => $show_div]);
 }