Title: last selected on combobox on reload Post by: wolfnbasti on June 06, 2014, 02:03:05 PM Hello, I'd like to have my last selected combobox option listed as the default/first displayed option on reload. From your examples I see how to do it if the combobox options are embedded in html but not if I'm loading from a Db, or external source. Can you help? Thanks.
<select id="client-select" class="easyui-combobox" style="width:250px;" data-options="{ url: '/.../clients', method: 'GET', editable: false, valueField: 'clientId', textField: 'clientName', onSelect: function(client) { document.cookie='client=' + client.clientId + '; PATH=/'; $('#RD').combobox({'url': '/.../clients/' + client.clientId + '/resourceDefs'}); $('#RD').combobox('reload'); $('#resourceDef-select').combobox({'url': /.../clients/' + client.clientId + '/resourceDefs'}); $('#resourceDef-select').combobox('reload'); }, }" > </select> Title: Re: last selected on combobox on reload Post by: wolfnbasti on June 06, 2014, 03:47:41 PM Corrected source: to clear up a copy/paste issue, it is the combobox generated with the url: '.../clients', that I'd to reload with the previous selection. Thanks.
<select id="client-select" class="easyui-combobox" style="width:250px;" data-options="{ url: '.../clients', method: 'GET', editable: false, valueField: 'clientId', textField: 'clientName', onSelect: function(client) { document.cookie='client=' + client.clientId + '; PATH=/'; clientCookie = client.clientId; $('#RD').edatagrid({'url': '..../clients/' + client.clientId + '/resourceDefs'}); $('#RD').edatagrid('reload'); $('#resourceDef-select').combobox({'url': '..../clients/' + client.clientId + '/resourceDefs'}); $('#resourceDef-select').combobox('reload'); }, }" > </select> Title: Re: last selected on combobox on reload Post by: jarry on June 07, 2014, 05:44:42 AM If a data item has 'selected' property set to true, it will be selected when loaded successfully. All you need to do is to set 'selected' property for the specified item from your returned json data. Look at the following data, the 'Ruby' item will be selected since its 'selected' property is set to true.
Code: [{ Title: Re: last selected on combobox on reload Post by: wolfnbasti on June 18, 2014, 08:59:51 PM I don't think that will work in my case. Consider two users; the first user selected value is dog, the second user has selected cat. Thus for each user the default selected value if different. If I store the current selected value as a cookie and the users reloads their browser, how would I then get use the cookie value to set dog as the default/last selected value for the first user and cat for the second user?
Thanks. |