EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on February 28, 2013, 05:41:43 PM



Title: datagrid inline editing combo selected
Post by: devnull on February 28, 2013, 05:41:43 PM
Hi;

When using a combobox inline in a datagrid, which has one of the fields set to 'selected':true - it appears to have no effect and this option is not selected when clicking on the datagrid field.

It therefore requires 2 clicks, one to display the un-selected combobox, and a second click to select the record you want.

Can this be changed so that if selected:true is set, as soon as the user clicks on the element the default value is selected ?

We have a large datagrid where the user needs to go through each record and select a status, in 95% of cases this will always be the selected:true option and it would cut the number of clicks they need to make by 50%.

Thanks


Title: Re: datagrid inline editing combo selected
Post by: stworthy on March 01, 2013, 02:29:55 AM
When editing a datagrid row, the editor value(combobox) will be filled with the current row field value. It will ignore the selected row of combobox. To make the selected row of combobox to be the default value of current datagrid row, a possible way is to call 'setValue' method for the combobox in the onLoadSuccess event.
Code:
$('#dg').datagrid({
columns:[[
{field:'productid',width:100,
editor:{
type:'combobox',
options:{
valueField:'productid',
textField:'productname',
url:'../datagrid/products.json',
required:true,
onLoadSuccess:function(rows){
for(var i=0; i<rows.length; i++){
var row = rows[i];
if (row.selected){
$(this).combobox('setValue', row.productid);
return;
}
}
}
}
}
}
]]
});


Title: Re: datagrid inline editing combo selected
Post by: devnull on March 01, 2013, 03:06:34 AM
Thanks, I think that effectively means that the selected option does not work when used in a datagrid.

But could it be changed such that if the field is null, then the selected value will be automatically selected.

The reason is, with a datagrid 100 lines long, it is the difference between 50 click and 100 clicks !

Thanks again for all the support.