EasyUI Forum
May 17, 2024, 08:28:29 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: How to get Checkbox value from Datagrid editor  (Read 14356 times)
patana
Jr. Member
**
Posts: 50


View Profile
« on: March 27, 2015, 08:10:46 PM »

Dear all,
How to get Checkbox value from Datagrid editor type=checkbox?
Thanks all.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 28, 2015, 05:40:57 AM »

The 'checkbox' editor has 'on' and 'off' options that indicate the checked and unchecked values.
Code:
<th field="status" width="50" data-options="
editor:{
type:'checkbox',
options:{
on: 'P',
off: 'N'
}
}
">Status</th>
Logged
patana
Jr. Member
**
Posts: 50


View Profile
« Reply #2 on: March 30, 2015, 12:36:54 AM »

Code:
<th data-options="field:'status',width:15"  align='center' editor="{type:'checkbox',options:{on:'v',off:'n'}}">status</th>
function getRowIndex(target) {
            var tr = $(target).closest('tr.datagrid-row');
            return parseInt(tr.attr('datagrid-row-index'));
        }
function saverow(target){
  var status = $('#dg').datagrid('getEditor', {index: getRowIndex(target), field: 'status'});
  var v_status = $(status.target).val();
  alert(v_status)
}
And the result i got is alway 'v' even i did not check it.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: March 30, 2015, 01:59:32 AM »

You can use .is(':checked') to determine whether or not the checkbox editor is checked.
Code:
var status = $('#dg').datagrid('getEditor', {index: getRowIndex(target), field: 'status'});
if ($(status.target).is(':checked')){
  //...
}
Logged
patana
Jr. Member
**
Posts: 50


View Profile
« Reply #4 on: March 30, 2015, 02:05:22 AM »

Ok, got it!
Thanks.
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!