在后面的代码中添加Ext.Net.Gridpanel

时间:2014-12-16 14:43:34

标签: c# ext.net

我正在尝试使用数据库中的搜索结果构建多个网格面板。

但他们从未出现......

这是我的代码,它有什么问题?

http://pastebin.com/WuTZwZrP

编辑

好的,明白了。对于那些有相同问题的人,我通过将其添加到GridPanel来解决它:

RenderTo = this.ExtPanel.ClientID

在构建之后:

ext.GridPanel grid = this.BuildGridPanel(forwarder.Key, forwarder.Value);
grid.Render();
//this.ExtPanel.Controls.Add(grid);

1 个答案:

答案 0 :(得分:0)

        public void AddGridPanel()
        {
          Ext.Net.GridPanel g=new Ext.Net.GridPanel();
          Ext.Net.Store store1=new Ext.Net.Store();
          Model model = new Model();
          for (int i = 1; i < tas.getTaskDE().Count / 2; i++)
                {
                    fields = fields + "," + tas.getTaskDE()[i].FieldName;
                    ModelField modelField = new ModelField();
                    modelField.Name = tas.getTaskDE()[i].FieldName;
                    model.Fields.Add(modelField);

                    if (tas.getTaskDE()[i].Visibility == "true")
                    {
                        g.ColumnModel.Columns.Add(new ColumnBase[] { 
                        new Column 
                          {
                             Text = tas.getTaskDE()[i].FieldADName,
                             DataIndex = tas.getTaskDE()[i].FieldName,
                             Flex = 1
                          },
                         });
                    }
                }
          SqlDataSource s = new SqlDataSource();
          s.ConnectionString =ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
          s.SelectCommand = query;
          store1.Model.Add(model);
          store1.DataSource = s;
          store1.DataBind();
          g.Store.Add(store1);
          g.Render(this.Form);
        }

动态网格面板的一个例子希望它有所帮助