EXT2联动选框 (Linked Combos Tutorial for Ext 2)

简介: Tutorial:EXT2联动选框 From Learn About the Ext JavaScript Library Jump to: navigation, search Summary: Very simple example of linked combos ...

Tutorial:EXT2联动选框

From Learn About the Ext JavaScript Library

Jump to: navigation, search
Summary: Very simple example of linked combos for Ext 2
Author: Jozef Sakalos
Published: October 20, 2007
Ext Version: 2.0
Languages: en.pngEnglish

Contents

[hide]

img_eda42ec0ff1711562683dd5494682118.png Preface

This is more example than tutorial as this is that simple that it only needs a brief explanation than step-by-step approach of proceeding from simple to complex. The whole example consists of two files: lcombo.html and lcombo.js.

img_eda42ec0ff1711562683dd5494682118.png lcombo.html



<html>
<head>
    <meta>
    <link>
    <script></script>
    <script></script>
    <script></script>
    
    <script>
        Ext.onReady(LCombo.app.init, LCombo.app);
    </script>
    <title>Linked Combos Example</title>
</head>
<body>
</body>
</html>

This is in fact the minimum html markup for an Ext application to run. Don't forget to change references to Ext libraries and resources according to your Ext installation.

img_eda42ec0ff1711562683dd5494682118.png lcombo.js


 

Ext. = ;
 
Ext., , ;
 
LCombo. = 
     , 
    ,, 
    ,, 
    ,, 
;
 
LCombo. = 
     , , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
    ,, , 
;
 

LCombo. =  
    
 
    
 
    
 
    
     
 
        
        init:  
             form =  Ext.
                 renderTo:document.
                ,width: 
                ,height: 
                ,style:
                ,bodyStyle:
                ,title:
                ,defaults: xtype:
                ,items:
                     fieldLabel:
                    ,displayField:
                    ,valueField:
                    ,store:  Ext..
                         fields:, 
                        ,data:LCombo.
                    
                    ,triggerAction:
                    ,mode:
                    ,listeners:select:fn:combo, value 
                         comboCity = Ext.;        
                        comboCity.;
                        comboCity.., combo.;
                        
                    
 
                ,
                     fieldLabel:
                    ,displayField:
                    ,valueField:
                    ,id:
                    ,store:  Ext..
                         fields:, , 
                        ,data:LCombo.
                    
                    ,triggerAction:
                    ,mode:
                    ,lastQuery:
                
            ;
        
    ;
; 
 

A form with two combos is created in this file with two little pieces of magic:

  • countries combo (the parent combo) has select event listener that, when executed, filters the cities combo (the child combo) based on the currently selected country
  • cities combo has lastQuery:"". This is to fool internal combo filtering routines on the first page load. The cities combo just thinks that it has already been expanded once.

img_eda42ec0ff1711562683dd5494682118.png Gotchas

The example is extremely simple and it does not take into account that internal logic of ComboBox filters the store too. That means that if you start to type into the cities combo, the filter set by countries combo select listener is first cleared and then the typed letters are used to filter the cities combo.

If you need more clever application of linked combos the best way is to listen to combo's beforequery event, do your own filtering logic in the event handler and return false to prevent the execution of the internal query logic. Use doQuery method of Ext ComboBox as the model.

目录
相关文章
SAP Fiori Elements - Smart table add button debug 2 setDirty
SAP Fiori Elements - Smart table add button debug 2 setDirty
107 0
SAP Fiori Elements - Smart table add button debug 2 setDirty
|
XML 数据格式
SAP Fiori Elements List Report Smart Table Toolbar 的 XML 视图实现
http://localhost:8080/resources/sap/suite/ui/generic/template/ListReport/view/fragments/SmartTableToolbar.fragment.xml SmartTableToolbar.fragment.xml 里,包含了 BreakoutActions.fragment:
120 0
SAP Fiori Elements List Report Smart Table Toolbar 的 XML 视图实现
如何查看 SAP Fiori Elements List Report Table 都支持哪些设置
我之前写过一篇文章:答网友提问:使用 SAP Fiori Tools 创建的 Fiori Elements 应用,如何进行二次开发?,在 manifest.json 设置里,能够对 List Report 里的 table 进行设置:
117 0
如何查看 SAP Fiori Elements List Report Table 都支持哪些设置
jQuery.sap.declare(cus.crm.notes.ext.Component);
Created by Wang, Jerry, last modified on Mar 06, 2015
88 0
jQuery.sap.declare(cus.crm.notes.ext.Component);
|
JavaScript 前端开发
|
JavaScript 前端开发
|
索引 数据格式 JSON
ExtJs之Ext.data.Store
Ext.data.Store的基本用法在使用之前,首先要创建一个Ext.data.Store的实例,如下面的代码所示。     1 var data = [ 2 ['boy', 0], 3 ['girl', 1] 4 ]; 5 6 var store = new Ext.
1035 0
|
XML JSON JavaScript
Ext Gantt Web甘特图--DataStore
和甘特图打交道,就不得不和DataStore打交道,甘特图中的数据是存放类型为Store 的数据存储器中,通过指定甘特图中的store 属性来设置表格中显示的数据,通过调用store 的load 或reload方法可以重新加载表格中的数据。
991 0
|
JavaScript 数据安全/隐私保护
ext designer
引用:http://liu78778.iteye.com/blog/622794 今天Extjs主页上的Ext Designer预售终于改成了发售,兴奋了一下下 点击进去之后,竟然发现了有下载选项         下载之后得到一个近20M的安装包     双击安装。
867 0