zoukankan      html  css  js  c++  java
  • EXTJS学习系列提高篇:第二十七篇(转载)作者殷良胜,ext2.2打造Ext.form.ComboBox系列动态绑定

    本篇介绍了将数据动态绑定到Ext.form.ComboBox,采取后台读数据库的方式.支持手写和联想功能,还提供显示提示消息的效果和改变ComboBox的宽度和高度.

    效果图如下:

    前台代码显示如下:

     <form id="form1" runat="server">
        <div><div id="hello"></div>
        <script type="text/javascript">   
        //动态绑定数据
        function ready()
        {      
            Ext.QuickTips.init();
           
            var store = new Ext.data.Store
            ({
                proxy: new Ext.data.HttpProxy({url:"comboJson.aspx?Flag=1"}), // 数据源
                reader: new Ext.data.JsonReader({totalProperty:"totalPorperty",root:"result",fields:[{name: 'ID'},{name: 'TypeCName'}]})// 如何解析
            });
            store.load();
            var comboBox = new Ext.form.ComboBox
            ({    
                tpl: '<tpl for="."><div ext:qtip="提示:ID={ID};TypeCName={TypeCName}" class="x-combo-list-item">{TypeCName}</div></tpl>',
                id:"ComboBox_ID",
                editable:true,//默认为true,false为禁止手写和联想功能
                store:store,
                emptyText:'请选择',
                mode: 'local',//指定数据加载方式,如果直接从客户端加载则为local,如果从服务器断加载 则为remote.默认值为:remote
                typeAhead: true,
                triggerAction: 'all',
                valueField:'ID', 
                displayField:'TypeCName',
                selectOnFocus:true,
                renderTo:'hello',
                160,
                resizable:true
            });        
        }
        Ext.onReady(ready);
        </script>
        </div>
        </form>

    后台代码显示如下:

     private void Bind_AllData()
            {
                DataSet ds = SampleBusiness.GetMoreRowByTableName("TypeTable");
                string json = "";
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    json = CommonUtil.GetJsonString(ds);
                    int count = ds.Tables[0].Rows.Count;
                    json = "{totalPorperty:" + count + ",result:" + json + "}";
                }
                else
                {
                    json = "错误";
                }
                Response.Write(json);
            }

    版权说明

      如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
      作      者:温景良
      文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

  • 相关阅读:
    写一个webpack plugin
    element的隐藏组件滚动条el-scrollbar使用
    iview 父组件动态传值给子组件
    RabbitMQ + Springboot +“Hello Word”
    Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected end of settings but encountered additional conte
    java.nio.file.NoSuchFileException
    A.CTable 自动创建数据表
    mybatis 动态添加表,查看表,添加数据
    异常:Error resolving template "xxx", template might not exist or might not be accessible...解决办法
    Springboot项目启动后访问不到Controller
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1325697.html
Copyright © 2011-2022 走看看