首页新闻找找看学习计划

Ext.Net 中GridPanel 添加ComboBox时出现错误

0
悬赏园豆:10 [已关闭问题] 关闭于 2017-05-05 17:13

GridPanel的列是动态生成的,而且是可以进行的列编辑的。

而我把行上的其中一列,替换成ComboBox时,出现了错误。

错误信息:Error during ClientConfig initialization. StoreID 

 Ext.Net.ComboBox cmb = new Ext.Net.ComboBox();
                    if (!string.IsNullOrEmpty(strAllowBlank))
                    {
                        cmb.AllowBlank = true;
                    }
                    if (!string.IsNullOrEmpty(strRegex))
                    {
                        cmb.Regex = strRegex;
                    }
                    if (!string.IsNullOrEmpty(strMaxLength))
                    {
                        cmb.MaxLength = Convert.ToInt32(strMaxLength);
                    }
                    if (!string.IsNullOrEmpty(strListeners))
                    {
                        cmb.Listeners.Change.Handler = strListeners;
                    }
                    if (!string.IsNullOrEmpty(strEditable))
                    {
                        cmb.Editable = false;
                    }
                    if (!string.IsNullOrEmpty(strStoreID))
                    {
                        cmb.StoreID = strStoreID;
                    }
                    cmb.TypeAhead = true;
                    cmb.ForceSelection = true;
                    cmb.DisplayField = "ItemCode";
                    cmb.ValueField = "ItemName";
                    cmb.MinChars = 1;
                    cmb.ListWidth = 400;
                    cmb.PageSize = 10;
                    cmb.ItemSelector = "tr.list-item";


                    StringBuilder sb = new StringBuilder();
                    sb.Append(" <tpl for=\".\"><tpl if=\"[xindex] == 1\">");
                    sb.Append("<table class=\"cbStates-list\" ><tr>");
                    sb.Append("<th style=\"color: #2f353b !important;\">物料编码</th>");
                    sb.Append(" <th style=\"color: #2f353b !important;\">物料名称</th>");
                    sb.Append("<th style=\"color: #2f353b !important;\">存货量</th>");
                    sb.Append("</tr> </tpl>");
                    sb.Append("<tr class=\"list-item\">");
                    sb.Append("<td style=\"padding:3px 0px;\">{ItemCode}</td>");
                    sb.Append("<td>{ItemName}</td>");
                    sb.Append("<td>{OnHand}</td>");
                    sb.Append("</tr> <tpl if=\"[xcount-xindex]==0\">");
                    sb.Append(" </table> </tpl> </tpl>");
                    cmb.Template.Html = sb.ToString();

                    col.Editor.Add(cmb);
                    GridPanel.AddColumn(col);//到这一步的时候出现错误了。

请问这个问题有遇到的朋友没有?该如何解决啊?

Vincent8464的主页 Vincent8464 | 初学一级 | 园豆:41
提问于:2017-05-03 18:18
< >
分享
所有回答(1)
0
 HttpProxy proxy = new HttpProxy
            {
                Method = HttpMethod.POST,
                Url = "../../../Handlers/BoneWL.ashx"
            };

                    // Create Reader
                    Ext.Net.JsonReader reader = new Ext.Net.JsonReader
                    {
                        Root = "plants",
                        TotalProperty = "total",
                        Fields = {
                new RecordField("ItemCode"),
                new RecordField("ItemName"),
                new RecordField("OnHand") 
            }
                    };

                    // Add Proxy and Reader to Store
                    Store store = new Store
                    {
                        Proxy = { proxy },
                        Reader = { reader },
                        AutoLoad = false
                    };

                    // Create ComboBox
                    Ext.Net.ComboBox cmb = new Ext.Net.ComboBox
                    {
                        DisplayField = "ItemCode",
                        ValueField = "ItemCode",
                        TypeAhead = false,
                        LoadingText = "加载中...",
                        Width = 240,
                        PageSize = 10,
                        HideTrigger = true,
                        ItemSelector = "tr.list-item",
                        MinChars = 1,
                        Store = { store }
                    };
                    
                    cmb.Listeners.TriggerClick.Handler = "UseDirectEvents('1');WinRowCancelEdit();";
                    cmb.Triggers.Add(new FieldTrigger() { Icon = TriggerIcon.Search });
                    cmb.TriggerIcon = TriggerIcon.Search;
                    StringBuilder sHtml = new StringBuilder();
                    sHtml.Append(" <tpl for=\".\"><tpl if=\"[xindex] == 1\">");
                    sHtml.Append("<table class=\"cbStates-list\" ><tr>");
                    sHtml.Append("<th style=\"color: #2f353b !important;\">ItemCode</th>");
                    sHtml.Append(" <th style=\"color: #2f353b !important;\">ItemName</th>");
                    sHtml.Append("<th style=\"color: #2f353b !important;\">OnHand</th>");
                    sHtml.Append("</tr> </tpl>");
                    sHtml.Append("<tr class=\"list-item\">");
                    sHtml.Append("<td style=\"padding:3px 0px;\">{ItemCode}</td>");
                    sHtml.Append("<td>{ItemName}</td>");
                    sHtml.Append("<td>{OnHand}</td>");
                    sHtml.Append("</tr> <tpl if=\"[xcount-xindex]==0\">");
                    sHtml.Append(" </table> </tpl> </tpl>");
                    cmb.Template.Html = sHtml.ToString();

这个是用代码创建combobox,可以多列显示,模糊查询,ajax获取数据。

直接添加到页面上就可以了。如:panel1.add(cmb);

Vincent8464 | 园豆:41 (初学一级) | 2017-05-05 17:13

加到gridpanel的编辑列中:

col.Editor.Add(cmb);——先加到编辑咧中
GridPanel.AddColumn(col);——然后再加到gridpanel的列中

支持(0) 反对(0) Vincent8464 | 园豆:41 (初学一级) | 2017-05-05 17:16

示例:

http://examples.ext.net/#/Form/ComboBox/Custom_Search/

支持(0) 反对(0) Vincent8464 | 园豆:41 (初学一级) | 2017-05-05 17:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册