Extjs-simple and Dynamic ComboBox

Source: Internet
Author: User

1. First

2. Ext code

 

Code

 // Set the data source parameters of the ComboBox list
VaR comboxstore = new Ext. Data. Store ({
Proxy: New Ext. Data. httpproxy ({
URL: "http://www.cnblogs.com/Service/SystemService/RoleService.ashx? Method = getallroles"
}),
Reader: New Ext. Data. jsonreader ({
Root: 'table ',
Totalproperty: 'recordcount ',
ID: 'roleid ',
Fields: ['roleid', 'rolename']
})
});

Comboxstore. Load ();

// Role drop-down list
VaR rolecombox = new Ext. Form. ComboBox ({
ID: 'rcombox ',
// Xtype: 'combo ',
Fieldlabel: 'Role ',
Emptytext: 'select the role ',
Name: 'rolename ',
Anchor: '20140901 ',
Store: comboxstore,
Displayfield: 'rolename ',
Valuefield: 'roleid ',
Hiddenname: 'roleid ',
Typeahead: True,
Mode: 'remote ',
Triggeraction: 'all ',
Selectonfocus: True,
Blanktext: 'Role cannot be null ',
Allowblank: false,
Editable: false
});

3. Question about the value submitted by ComboBox in the form

There are two methods:

1. Params: {roleid: Ext. getcmp ('rcombox'). getvalue ()}

Pass getvalue () through Params to get the value in valuefield

2. Configure hiddenname to save the value in valuefield. Otherwise, the value in the name attribute will be submitted, that is, the value of dispalyfield.

4. Parameter Introduction

Mode: Data Source mode local remote indicates that data is read from the server

Selectonfocus: If the value is true, the existing text of the field is automatically selected when the field obtains the focus.

Editable: True indicates that it can be edited.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.