Home  >  Article  >  Web Front-end  >  Some operational summaries about easyui checkbox

Some operational summaries about easyui checkbox

巴扎黑
巴扎黑Original
2018-05-12 13:44:457116browse

1. easyui adds checkbox to each line

{ field: 'id', title: '编号', checkbox: true }

2. Remember the previously selected checkbox when easyui paging

Set the dField attribute of easyui

dField: data Fields are generally primary keys or uniquely determined fields

3. Get checked rows:

 var rows = $('#datagrid').datagrid('getChecked');

4. Determine whether the checkbox is all selected:

var allFlg = $(".datagrid-header-check").find("input").is(":checked");

5. checkbox In the pop-up layer, remember the selected checkbox. When the pop-up layer pops up again, reset the selected checkbox

First save the idField of the selected checkbox row into the global variable array

// 保存已选的checkbox
  var checkboxs = new Array();
  function selectCheckBox() {
    var rows = $('#datagrid').datagrid('getChecked');//获取已勾选的行
    checkboxs = new Array();//全局变量 
    注:这里要重新new,不然会保留上一次的勾选结果
    for (var i = 0; i < rows.length; i++) {
      checkboxs [i] = (rows[i][idField的值]);
      }
  }
  下次进来时执行
  onLoadSuccess: function (data) {
               if (data.rows.length > 0) {
                     for (var i = 0; i < data.rows.length; i++) {
        //判断该idField是否为数组中的元素
                           if (checkboxs .in_array(data.rows[i].idField的值)) {
          //将该index的行的checkbox勾上
                                 $("#datagrid").datagrid("selectRow", i);
                           }
                     }
               }
         },
  // 判断字符串是否是数组里的元素
  Array.prototype.in_array = function (element) {
       for (var i = 0; i < this.length; i++) {
             if (this[i] == element) {
                   return true;
             }
       }
       return false;
  }  


The above is the detailed content of Some operational summaries about easyui checkbox. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn