EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rangaNadha on November 18, 2015, 10:40:32 PM



Title: Datagrid Inline edit: show/hide editors dynamically
Post by: rangaNadha on November 18, 2015, 10:40:32 PM
Hi,

How can we show/hide cell editors in the datagrid based on change comobo box in another cell, while inline editing?
Can any one provide an example?



Thanks in advance.


Title: Re: Datagrid Inline edit: show/hide editors dynamically
Post by: jarry on November 18, 2015, 11:55:19 PM
When begin to edit a row, the 'onBeginEdit' event fires, in which you can get all the editors and attach all events on them. Please refer to the code below:
Code:
$('#dg').datagrid({
onBeginEdit: function(index,row){
var dg = $(this);
var ed1 = dg.datagrid('getEditor', {index:index,field:'productid'});
$(ed1.target).combobox({
onChange: function(value){
var ed2 = dg.datagrid('getEditor', {index:index,field:'listprice'});
// $(ed2.target).numberbox('disable');  // disable the editor
$(ed2.target).parent().hide();  // hide the editor
}
})
}
})


Title: Re: Datagrid Inline edit: show/hide editors dynamically
Post by: rangaNadha on November 19, 2015, 06:16:07 AM
Thanks for the response.

But, after adding that code. In the edit mode combobox is showing empty. It is not showing the previous saved value.

Is this happening because of  "$(ed1.target).combobox({"




Title: Re: Datagrid Inline edit: show/hide editors dynamically
Post by: rangaNadha on November 20, 2015, 05:20:05 AM
I fixed it, after adding the onchange function. Manually i set the previous value. Now it is working fine. Thnx Jerry.