EasyUI Forum
May 03, 2024, 04:09:20 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, turn on/off selected rows....  (Read 18015 times)
2plus2
Jr. Member
**
Posts: 75


View Profile
« on: July 27, 2013, 03:20:38 PM »

I have a datagrid that has the check box column, and I would like to enable/disable the checkbox depending on row data passed to the datagrid.

I'm assuming that I can't do this with the default checkbox property, and will have to write a custom editor via formatter.

Is there a better way to selectively enable / disable a checkbox on a row by row basis?

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


View Profile Email
« Reply #1 on: July 27, 2013, 06:36:42 PM »

Another solution is to loop all the rows and call 'checkRow' method on specified rows in 'onLoadSuccess' event.
Code:
$('#dg').datagrid({
onLoadSuccess: function(data){
for(var i=0; i<data.rows.length; i++){
var row = data.rows[i];
if (row.listprice>30){
$(this).datagrid('checkRow',i);
}
}
}
});
Logged
2plus2
Jr. Member
**
Posts: 75


View Profile
« Reply #2 on: July 29, 2013, 10:35:02 PM »

Thanks - but what I'm looking for is to enable or disable the check box on a row by row basis. For some data grids, we want to show the data - but the user can't select (or unselect) some of the rows.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 30, 2013, 01:27:18 AM »

Try this:
Code:
$('#dg').datagrid({
onLoadSuccess: function(data){
var opts = $(this).datagrid('options');
for(var i=0; i<data.rows.length; i++){
var row = data.rows[i];
if (row.listprice>30){
var tr = opts.finder.getTr(this,i);
tr.find('input[type=checkbox]').attr('disabled','disabled');
//$(this).datagrid('checkRow',i);
}
}
}
});
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!