The project has the following requirement: select an organization name during logon, and enter an account to log on. The next time you log on, the last logon page is displayed in the "unit selection" box.
The specific implementation is as follows:
{
Xtype: 'combo ', // here is the combo of the unit selected
Id: 'orgname ',
Store: orgStore,
Name: 'orgname ',
EmptyText: 'select the unit ',
DisplayField: 'orgname ',
ValueField: 'dbname ',
Editable: false,
ForceSelection: true,
TriggerAction: 'all ',
Shadow: 'framework ',
HiddenName: 'dbname ',
Listeners :{
Select: function () {// Add one select function. When this function is selected, save the selection result to the cookie.
Savedbname = Ext. getCmp ('orgname'). getValue ();
Ext. util. Cookies. set ('savedbname', savedbname );
}
}
}
Var orgStore = new Ext. data. JsonStore ({// This is the Combo data Source selected by the Unit
Url: 'test/LoginOrgSelectServlet ',
Root: 'orgselect ',
Fields: ['orgname', 'dbname'],
AutoLoad: true,
Listeners: {load: function () {// Add a load listener to the store.
Var cookiedata = Ext. util. Cookies. get ("savedbname ");
If (cookiedata! = Null) {Ext. getCmp ('orgname'). setValue (cookiedata);} // set the combo value when the data in the cookie is not empty.
}}
});