1. 程式人生 > >解決easy ui datagrid 複選框選擇和顯示,或不可操作的問題

解決easy ui datagrid 複選框選擇和顯示,或不可操作的問題

1.1

onSelect:function(rowIndex,rowData){

                                     //如果該行不能被選中,則呼叫取消選中方法

                                      if(CanNotCheck(rowData)){

                                         setTimeout(function(){

                                                $('#tt').datagrid('unselectRow',rowIndex);

                                         },0);

                                     }

                                 }

functionCanNotCheck(r){

              if(r.tjzt_zw=="已提交")

                   return true;

              return false;

           }

1.2

onLoadSuccess:function (data) {

                                 //模擬測試載入成功後資料Id大於20的都勾選中,並禁用checkbox

                                 for (var i = 0; i < data.rows.length;i++) {

                                     if (data.rows[i].dyqrzt=='1') {

                                        //$("#tt").datagrid('checkRow', i);

                                         //禁用checkbox

                                        //$(".datagrid-row[datagrid-row-index=" + i + "]input[type='checkbox']")[0].style.visibility="hidden";

                                         //var a=$(".datagrid-row[datagrid-row-index=" + i + "]input[type='checkbox']")[0];

                                         //a.parentNode.removeChild(a);

                                        //$(".datagrid-row[datagrid-row-index=" + i + "]input[type='checkbox']")[0].checked =false;

                                        $(".datagrid-row[datagrid-row-index=" + i + "]input[type='checkbox']")[0].disabled =true;

                                        $(".datagrid-row[datagrid-row-index=" + i + "]input[type='checkbox']")[0].style.visibility="hidden";

                                     }

                                 }

                             },

1.3

                             onClickRow:function(rowIndex, rowData){

                       //載入完畢後獲取所有的checkbox遍歷

                      $("input[type='checkbox']").each(function(index, el){

                           //如果當前的複選框不可選,則不讓其選中

                           if (el.disabled == true) {

                                    $('#tt').datagrid('unselectRow', index - 1);

                           }

                       })

                   },

1.4

                   onCheckAll: function(rowIndex,rowData){

                                     //載入完畢後獲取所有的checkbox遍歷

                                    $("input[type='checkbox']").each(function(index, el){

                                         if (el.disabled == true) {

                                            $('#tt').datagrid('uncheckRow',index - 1);

                                         }

                                     })

                                 },