Ext. Form. ComboBox common attributes
Tags: extjs JS combo
JS Code
- VaR combo = new Ext. Form. ComboBox ({
- Store: New Ext. Data. simplestore ({
- Fields: ['value', 'text'],
- Data: [['000000', 'pediatric dicao'], ['000000', 'Adult dicao'], ['000000', 'xiuyuan']
- }),
- Hiddenname: 'product _ Code', // name of the Input submitted to the background
- Mode: 'local', // data loading mode, 'local' local loading, and 'remote' Remote Loading
- Valuefield: 'value', // Value Field
- Displayfield: 'text', // display field
- Value: '000000', // default value. It must be set to the value submitted to the background. Do not set it to display text.
- Emptytext: 'Please select', // prompt message
- Mode: 'local', // data loading mode. Local indicates local data.
- Triggeraction: 'all', // display all the following data. Set triggeraction to.
- Readonly: false, // read-only. If it is true, it cannot be edited and cannot be clicked.
- Editable: false, // whether it can be edited. If it is set to true, it can be input manually.
- Pagesize: 0 // the pagination button is displayed when the value is greater than 0.
- })
If you use the combo control in editorgrid, after editing, you will find that the displayed values are encoded rather than the displayed values. You can add the Renderer method in columnmode to modify the displayed values. The following is an example from the combo source code.
JS Code
- Ext. util. format. comborenderer = function (Combo ){
- Return function (value ){
- VaR record = combo. findrecord (combo. {@ link # valuefield}, value );
- Return record? Record. Get (combo. {@ link # displayfield}): combo. {@ link # valuenotfoundtext };
- }
- }
- // Create the combo instance
- VaR combo = new Ext. Form. ComboBox ({
- {@ Link # typeahead}: True,
- {@ Link # triggeraction}: 'all ',
- {@ Link # lazyrender}: True,
- {@ Link # mode}: 'local ',
- {@ Link # store}: New Ext. Data. arraystore ({
- ID: 0,
- Fields :[
- 'Myid ',
- 'Displaytext'
- ],
- Data: [[1, 'item1'], [2, 'item2']
- }),
- {@ Link # valuefield}: 'myid ',
- {@ Link # displayfield}: 'displaytext'
- });
- // Snippet of column model used within Grid
- VaR CM = new Ext. Grid. columnmodel ([{
- ...
- },{
- Header: "Some Header ",
- Dataindex: 'whatever ',
- Width: 130,
- Editor: combo, // specify reference to combo instance
- Renderer: Ext. util. format. comborenderer (Combo) // pass combo instance to reusable Renderer
- },
- ...
- ]);
Combo is very convenient to use, and many attributes are not used at ordinary times. They all have default values, such as entering several words for data query, display template, and drop-down display height. If you are not satisfied with its display content or method, you can modify its attributes to expand it. The comments in the source code are very detailed and can be modified according to the prompted information.