EasyUI Forum
May 20, 2024, 03:19:53 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: last selected on combobox on reload  (Read 13148 times)
wolfnbasti
Newbie
*
Posts: 16


View Profile
« 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>
Logged
wolfnbasti
Newbie
*
Posts: 16


View Profile
« Reply #1 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>
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #2 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:
[{
"value":1,
"text":"Java"
},{
"value":2,
"text":"C#"
},{
"value":3,
"text":"Ruby",
"selected":true
}]
Logged
wolfnbasti
Newbie
*
Posts: 16


View Profile
« Reply #3 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.
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!