EasyUI Forum
May 15, 2024, 01:33:02 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datagrid Checkbox by GroupView  (Read 3540 times)
pakde
Newbie
*
Posts: 2



View Profile
« on: August 08, 2019, 09:17:24 PM »

hi, please help me.
how to apply the check box only based on the group selected in DataGrid.

my code :
Code:
<table class="easyui-datagrid" id="candu" style="width:100%; height:485px"
           method="get"
           url="listlab"
           singleSelect="false"
           fitColumns="true"
           sortName="column4"
           rowNumbers="true"
           sortOrder="asc"
           multiSort="true"
           data-options="
                view:groupview,
                groupField:'column4',
                groupFormatter:function(value, rows) {
return value + ' - ' + rows.length + ' Data';
                }
           ">
        <thead>
            <tr>
                <th field="id" width="10px" checkbox="true" ></th>
                <th field="column1" width="20px">Column 1</th>
                <th field="column2" width="20px">Column 2</th>
                <th field="column3" width="30px" editor="textbox">Column 3</th>
                <th field="column4" width="20px" sortable="true" >Column 4</th>
            </tr>
        </thead>
    </table>

thanks...
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 09, 2019, 12:41:54 AM »

First of all, append a checkbox element ahead of the group title.
Code:
groupFormatter:function(value, rows){
  var s = value + ' - ' + rows.length + ' Item(s)';
  s = '<input type="checkbox" onclick="checkGroup(\''+value+'\',event)">'+s;
  return s;
}
Define the 'checkGroup' function to check the group rows.
Code:
function checkGroup(value,event){
  value = $.trim(value);
  var dg = $('#dg');
  var groups = dg.datagrid('groups');
  var group = null;
  for(var i=0; i<groups.length; i++){
    if (groups[i].value == value){
      group = groups[i];
      break;
    }
  }
  var checked = $(event.target).is(':checked');
  for(var i=group.startIndex; i<group.startIndex+group.rows.length; i++){
    dg.datagrid(checked?'checkRow':'uncheckRow',i)
  }
}
Logged
pakde
Newbie
*
Posts: 2



View Profile
« Reply #2 on: August 09, 2019, 07:37:48 AM »

wow amazing Shocked, thanks for the help stworthy case closed.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!