示例#1
0
 public function init()
 {
     parent::init();
     $request = AH::merge(['wrapper' => 'results', 'term' => 'search:term'], $this->uses);
     $requests = [];
     $back_request = [];
     foreach ($request as $k => $v) {
         if ($k === 'term') {
             $requests[] = $v;
         } elseif (is_array($v)) {
             $requests[] = "{$k}:" . json_encode($v);
             $back_request[] = "{$k}:" . json_encode($v);
         } else {
             $requests[] = "{$k}:'{$v}'";
             $back_request[] = "{$k}:'{$v}'";
         }
     }
     \Yii::configure($this, ['format' => 'html', 'filterInputOptions' => ['id' => 'id'], 'filter' => Select2::widget(['attribute' => 'id', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['list']), 'settings' => ['ajax' => ['data' => new JsExpression('function(term,page) { return {' . implode(', ', $requests) . '}; }')], 'initSelection' => new JsExpression('function (elem, callback) {
                     var id=$(elem).val();
                     $.ajax("' . Url::toRoute(['list']) . '?id=" + id, {
                         dataType: "json",
                         data : {' . implode(', ', $back_request) . '}
                     }).done(function(data) {
                         callback(data.results[0]);
                     });
                 }')]])]);
 }
示例#2
0
 public function init()
 {
     parent::init();
     \Yii::configure($this, ['attribute' => 'email', 'label' => \Yii::t('hipanel', 'Email'), 'format' => 'html', 'value' => function ($model) {
         return Html::a($model->client ?: $model->login, ['/client/contact/view', 'id' => $model->client ? $model->client_id : $model->id]);
     }, 'filterInputOptions' => ['email' => 'email'], 'filter' => Select2::widget(['attribute' => 'email', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['/client/contact/email-list'])])]);
 }
示例#3
0
 public function init()
 {
     if (is_callable($this->items)) {
         $callableItems = $this->items;
         $this->items = $callableItems();
     }
     parent::init();
 }
示例#4
0
 public function init()
 {
     parent::init();
     Yii::configure($this, ['visible' => Yii::$app->user->identity->type !== 'client', 'attribute' => 'seller_id', 'label' => Yii::t('hipanel', 'Can Manage'), 'format' => 'html', 'value' => function ($model) {
         return Html::a($model->client, ['/client/client/view', 'id' => $model->client_id]);
     }, 'filterInputOptions' => ['id' => 'client_id'], 'filter' => Select2::widget(['attribute' => 'seller_id', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['/client/client/list']), 'settings' => ['ajax' => ['data' => new JsExpression('function(term,page) { return {"rename[text]":"login",wrapper:"results", manager_only:true, client_like:term}; }')], 'initSelection' => new JsExpression('function (elem, callback) {
                     $.ajax("' . Url::toRoute(['/client/client/list']) . '?id=" + id, {
                         dataType: "json",
                         data : {"rename[text]":"login",wrapper:"results" }
                     }).done(function(data) {
                         callback(data.results[0]);
                     });
                 }')]])]);
 }
示例#5
0
 public function init()
 {
     parent::init();
     //$this->contentOptions=['class'=>'align-center'];
 }
示例#6
0
 public function init()
 {
     parent::init();
 }
示例#7
0
 public function init()
 {
     parent::init();
     $this->noteOptions = ArrayHelper::merge(['url' => $this->buildUrl('set-note')], $this->noteOptions);
 }