EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on February 14, 2014, 06:47:09 AM



Title: combobox and onBeforeLoad
Post by: rezzonico on February 14, 2014, 06:47:09 AM
Hi all,

I have a field with a combobox editor (the field is in a databgird).
I use the onBeforeLoad function in order to populate the content on the combox (the data is read from another datagrid).

Here is the code:
Code:
               {field:'Jptask',title:'Op',width:10,
                   editor: {
                      type: 'combobox',
                      options: {
                         onBeforeLoad:function() {
                            var rows = $('#dg_Jobtask').datagrid('getRows');
                            var json = [];
                            for (var i=0; i<rows.length; i++) {
                               json.push({ id: rows[i].Jptask, text: rows[i].Jptask })
                            }
                            $(this).combobox('loadData', json);
                         }
                      }
                   }
               },

All work as expected.
The only problem is that the onBeforeLoad function is executed only the first time when the user click on the combobox.
Is it possible to execute this function every time when the user click on the combobox ?

Thanks in advance for any help.
Miche


Title: Re: combobox and onBeforeLoad
Post by: stworthy on February 14, 2014, 08:27:54 AM
Please try to use 'onShowPanel' event that is triggered when click to drop down the content panel.
Code:
editor: {
    type: 'combobox',
    options: {
       onShowPanel:function() {
          //...;
       }
    }
}


Title: Re: combobox and onBeforeLoad
Post by: rezzonico on February 14, 2014, 08:59:09 AM
It works perfectly.
Thanks a lot !

Miche