EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sky-t on March 30, 2018, 08:18:37 AM



Title: Editable Datagrid combobox values depending on combobox
Post by: sky-t on March 30, 2018, 08:18:37 AM
Hi there,

i have an editable Datagrid. In one column i have a combobox and in the next column another combobox. The second combobox values depend on what clicked in the first.
How do i fill the values in the second combobox?

Thank you very much


Title: Re: Editable Datagrid combobox values depending on combobox
Post by: jarry on March 31, 2018, 05:31:57 AM
Please refer to the code below.
Code:
$('#dg').datagrid({
onBeginEdit: function(index,row){
var ed1 = $(this).datagrid('getEditor', {index:index,field:'col1'});
var ed2 = $(this).datagrid('getEditor', {index:index,field:'col2'});
$(ed1.target).combobox({
onChange: function(value){
$(ed2.target).combobox('reload', {
value: value
})
}
})
}
})


Title: Re: Editable Datagrid combobox values depending on combobox
Post by: sky-t on April 04, 2018, 09:13:38 PM
Hi jarry,

thank you for your replay.
Your code is working. But now i have an other problem.
When clicking a row in a datagrid the selected value of the combobox disapears but i have to keep the selected value.
How can i achieve this?

Thank you very much.


Title: Re: Editable Datagrid combobox values depending on combobox
Post by: sky-t on April 07, 2018, 10:46:59 AM
any ideas?

Thanks


Title: Re: Editable Datagrid combobox values depending on combobox
Post by: jarry on April 07, 2018, 08:13:38 PM
You should set the 'valueField' and 'textField' properties correctly to make the combobox's value match the bound field value of the editing row. Please look at this example https://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=material&dir=ltr&pitem=Row%20Editing%20in%20DataGrid&sort=

If your issue continues, please show some code snippets or a live example to demonstrate your issue.