EasyUI Forum
May 14, 2024, 12:14:00 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: Problem on default value for combotree in edatagrid  (Read 18321 times)
contestant
Newbie
*
Posts: 40


View Profile Email
« on: July 14, 2015, 05:51:40 PM »

Hi

Unfortunately, on usage combotree for datagrid inline editing, the default value not set automatically like combobox.
Please help me to solve this problem.

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


View Profile Email
« Reply #1 on: July 14, 2015, 06:19:19 PM »

The default value can be set by 'value' property, please refer to http://www.jeasyui.com/demo/main/index.php?plugin=ComboTree&theme=default&dir=ltr&pitem=Initialize%20Value%20for%20ComboTree
Logged
contestant
Newbie
*
Posts: 40


View Profile Email
« Reply #2 on: July 14, 2015, 07:21:55 PM »

Thanks for your replay, But this is not use for datagrid editor.
My combotree is a datagrid editor, So what can I do?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 14, 2015, 07:42:55 PM »

When editing a row, the editor's value is set with the field value bound to this editor. So please check your code carefully to see what the field value is before editing the row. Does it exist in your tree nodes or not.
Logged
contestant
Newbie
*
Posts: 40


View Profile Email
« Reply #4 on: July 15, 2015, 12:27:02 PM »

When I use textbox or combobox, the current value is set for them but when I use combotree the current value not select node on it.
So what is problem?
Logged
contestant
Newbie
*
Posts: 40


View Profile Email
« Reply #5 on: July 15, 2015, 02:10:10 PM »

I use this method for set default values on beginEditing:

Code:
onBeginEdit: function(index, row){
                $('.' +$(this).attr('id')+ 'Actions').fadeIn();
                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 ) ]);
                    }
                    else if( this.type == 'combotree' ){
                        var opts = $(this.target).combotree('options');
                        $(this.target).combotree('setValue', row[ ( opts.defaultValueField != '' ? opts.defaultValueField : this.field ) ]);
                    }
                });
            }
« Last Edit: July 15, 2015, 02:15:57 PM by contestant » Logged
contestant
Newbie
*
Posts: 40


View Profile Email
« Reply #6 on: July 15, 2015, 03:07:00 PM »

I realized that the cause of the error when loading data from the url.
Because setValue in combotree run before loading data that not exists until, And this is a bug!  Huh

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


View Profile Email
« Reply #7 on: July 15, 2015, 05:51:01 PM »

There are no bugs in 'setValue' method. Please refer to this example carefully, it works fine.

http://jsfiddle.net/gzw1rczk/
Logged
nawaitu
Newbie
*
Posts: 1



View Profile WWW Email
« Reply #8 on: August 28, 2015, 10:51:58 AM »

thanks for tips... I Have a problem so
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!