search

Home  >  Q&A  >  body text

This question is about how to change the code that excludes id99999 in this ID.

<div class="box box-primary">

    <div class="box-body">

        <?php Pjax::begin(); echo GridView::widget([

            'pjax' => true,

            'dataProvider' => $objDataProvider,

            'filterModel' => $objSearchModel,

            'responsive'=> true,

            'hover'=> true,

            'condensed'=> true,

            //'floatHeader'=> false,

            'columns' => [

                [

                    'attribute' => 'id', 

 (这里让他不包含id99999)

                    'label' => '编号',

                    'hAlign'=> GridView::ALIGN_CENTER,

                ],

                [

                    'attribute' => 'agent_id',

                    'label' => '代理编号',

                    'hAlign'=> GridView::ALIGN_CENTER,

                ],

                [

                    'attribute' => 'agent',

                    'label' => '昵称',

                    'value' => function($objModel) {

                        return $objModel->agent->screen_name;

                    },

                    'width'=>'150px',

                    'hAlign'=> GridView::ALIGN_CENTER,

                ],

                /*


BluefishBluefish2430 days ago1286

reply all(2)I'll reply

  • Summer

    Summer2018-07-20 15:01:29

    $newarray = $columns;

    foreach($columns as $key => $vo){

    if($vo['attribute']==99999){

    unset($newarray [$key]);

    }

    }

    print_r($newarray);//This is the new one without 99999 Array

    reply
    0
  • 无忌哥哥

    无忌哥哥2018-07-20 13:34:06

    Exclude it when searching the database, which is easier to handle. For templates, <?php if($id !=9999)?>

    reply
    0
  • Cancelreply