登陆

这问这段id里面 排除id99999的代码怎么改

<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,

                ],

                /*


# PHP
BluefishBluefish1195 天前529 次浏览

全部回复(2)我要回复

  • Summer

    Summer2018-07-20 15:01:29

    $newarray = $columns;

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

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

            unset($newarray [$key]);

        }

    }

    print_r($newarray);//这个就是去除了99999的新数组

    回复
    0
  • 无忌哥哥

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

    在搜索数据库的时候就排除,这样比较好处理。模版的话,<?php if($id !=9999)?>

    回复
    0
  • 取消回复发送