EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: 2plus2 on July 27, 2013, 03:20:38 PM



Title: Datagrid Checkbox, turn on/off selected rows....
Post by: 2plus2 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.


Title: Re: Datagrid Checkbox, turn on/off selected rows....
Post by: stworthy 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);
}
}
}
});


Title: Re: Datagrid Checkbox, turn on/off selected rows....
Post by: 2plus2 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.


Title: Re: Datagrid Checkbox, turn on/off selected rows....
Post by: stworthy 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);
}
}
}
});