当前位置:编程学习 > C#/ASP.NET >>

gridview全选与取值操作

gridview全选与取值操作

 

'columns'=>array(
            array(
                'class'=>'CCheckBoxColumn',
                //'header'=>'全选',
                //'value'=>'$data->id',
                //'checked'=>'true',
                'htmlOptions'=>array(
                    'width'=>'30',
                    'style'=>'text-align:center',
                ),
            ),

 

 

<div id="btn" style="width:100%; text-align:right; padding-top:20px"><?php教程 echo CHtml::ajaxLink('批量更新', array('link/dels'), array(
    'type'=>'POST',
    'timeout'=>'30000',
    'data'=>'js:{ids:jQuery("input[name='link-grid_c0[]']:checked").map(function(){ return $(this).val(); }).get()}',
    'beforeSend'=>'function(){ $("#btn").hide(); $("#load").show(); }',
    'success'=>'function(html){ alert(html); }',
    'complete'=>'function(){ $("#btn").show(); $("#load").hide(); }',
    'error'=>'function(a,b,c){ if(b=="timeout") { alert("本次执行过程超过30秒,请分批更新!"); }}',
));?></div>
<div id="load" style="display: none; text-align:right; width:100%; padding-top:20px">正在更新,请稍后......</div>
<script>
    var ids=jQuery("input[name='link-grid_c0[]']:checked").map(function(){ return $(this).val(); });
    //alert(ids.length);
</script>


取值

gridview 自定义value值
model里:

01 public function item($items,$name){

02         $returnValue='';

03         foreach($items as $n=>$item){

04                 if(isset($this->$name)){

05                         if($n==$this->$name){

06                                 $returnValue=$item;

07                         }

08                 }

09         }

10         return $returnValue;

11 }

view里:

1 array('name'=>'isPass','value'=>'$data->item(array('1'=>'是','0'=>'否'),'isProcess')','filter'=>array('1'=>'是','0'=>'否')),

更简单些

1 'value'=> '$data->ispass == "1" ? "是" : "否"',

补充:asp.net教程,基础入门 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,