EasyUI Forum
May 01, 2024, 03:16:14 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Select current item in combobox on editing datagrid row  (Read 8587 times)
contestant
Newbie
*
Posts: 40


View Profile Email
« on: April 05, 2015, 08:05:51 AM »

Hello

I have a problem on editing row of datagrid, When editing of row is began, Combo box has been not selected default value.

Please guide me!

Thanks  Wink
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 05, 2015, 06:07:09 PM »

What do you mean the 'selected default value'? Normally, you need to set the 'valueField' and 'textField' properties correctly when using the combobox editor. You also can change the combobox's value when editing a row.
Code:
$('#dg').datagrid({
onBeginEdit: function(index,row){
var ed = $(this).datagrid('getEditor', {index:index,field:'productid'});
if (ed){
$(ed.target).combobox('setValue', 'RP-LI-02');
}
}
})
Logged
contestant
Newbie
*
Posts: 40


View Profile Email
« Reply #2 on: April 05, 2015, 11:53:39 PM »

Thank's for your answer

I fixed this problem with a better solution, with an extra option parameter for datagrid, because my field value there is in another database field.

This solution automatically work in "onBeginEdit" event of datagrid;
Example:

Code:
var editors = $(this).edatagrid('getEditors', index);
                   
                $.each(editors, function() {
                    if( this.type == 'combobox' ){
                        var opts = $(this.target).combobox('options');
                        $(this.target).combobox('setValue', row[ ( opts.defaultValueField != '' ? opts.defaultValueField : this.field ) ]);
                    }
                });
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!