EasyUI Forum

General Category => General Discussion => Topic started by: contestant on July 14, 2015, 05:51:40 PM



Title: Problem on default value for combotree in edatagrid
Post by: contestant 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  ;)


Title: Re: Problem on default value for combotree in edatagrid
Post by: stworthy 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


Title: Re: Problem on default value for combotree in edatagrid
Post by: contestant 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?


Title: Re: Problem on default value for combotree in edatagrid
Post by: stworthy 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.


Title: Re: Problem on default value for combotree in edatagrid
Post by: contestant 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?


Title: Re: Problem on default value for combotree in edatagrid
Post by: contestant 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 ) ]);
                    }
                });
            }


Title: Re: Problem on default value for combotree in edatagrid
Post by: contestant 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!  ???

Thanks again


Title: Re: Problem on default value for combotree in edatagrid
Post by: stworthy 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/


Title: Re: Problem on default value for combotree in edatagrid
Post by: nawaitu on August 28, 2015, 10:51:58 AM
thanks for tips... I Have a problem so