EasyUI Forum
April 25, 2024, 05:49:08 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: Editable Datagrid combobox values depending on combobox  (Read 5999 times)
sky-t
Full Member
***
Posts: 145


View Profile
« 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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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
})
}
})
}
})
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #2 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.
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #3 on: April 07, 2018, 10:46:59 AM »

any ideas?

Thanks
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #4 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.
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!