Jul 05, 2011, 2:24 PM
How to add GridPanel to cardPanel in code behind
Hello and Good morning.
How can I add a grid from code behind in a cardpanel? I have no trouble defining store and reader for a grid that is already in the markup. However if I try to create grid totally from code behind, it's not working. IE gives a javascript error. Firefox does not give an error but does not display the grid as well. I think I'm really close though.
in my aspx page I have the following:
How can I add a grid from code behind in a cardpanel? I have no trouble defining store and reader for a grid that is already in the markup. However if I try to create grid totally from code behind, it's not working. IE gives a javascript error. Firefox does not give an error but does not display the grid as well. I think I'm really close though.
in my aspx page I have the following:
<ext:Panel ID="cardPanel" runat="server" Height="600" Title="Import Data" Layout="card" ActiveIndex="0" ClientIDMode="Static">
<LayoutConfig>
<ext:CardLayoutConfig DeferredRender="False" AutoDataBind="True" RenderHidden="True" />
</LayoutConfig>
<Items>
<ext:Panel ID="Panel2" runat="server" Height="300" Title="Title" Header="false">
<Items>
<ext:GridPanel ID="gridFldCompare" runat="server" ColumnLines="true" StripeRows="true" Height="400" TitleCollapse="true" Header="false" Margins="10 0 0 0" ClientIDMode="Static">
<Store>
<ext:Store runat="server" ID="storeFldCompare" ClientIDMode="Static">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="Test"/>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
</ext:GridPanel>
</Items>
</ext:Panel>
<ext:Panel ID="pnlCompareData" runat="server" Height="300" Title="Title" Header="false" ClientIDMode="Static">
<Items>
<ext:Button runat="server" Text="Compare">
<Listeners>
<Click Handler="Ext.net.DirectMethods.CompareFlds();" />
</Listeners>
</ext:Button>
</Items>
</ext:Panel>
</Items>
<Buttons>
<ext:Button ID="btnPrev" runat="server" Text="Prev" Disabled="true" Icon="PreviousGreen" ClientIDMode="Static">
<Listeners>
<Click Fn="PrevStep" />
</Listeners>
</ext:Button>
<ext:Button ID="btnNext" runat="server" Text="Next" Icon="NextGreen" ClientIDMode="Static">
<Listeners>
<Click Fn="NextStep" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Panel>
and my Ext.net.DirectMethods.CompareFlds(): foreach (DataTable dtDiff in dsImportDiff.Tables)
{
ExtJS.JsonReader rdr = new ExtJS.JsonReader();
rdr = GetReader(dtDiff);
Store store = new Store();
store.Reader.Add(rdr);
GridPanel grid = new GridPanel();
grid.ColumnModel.Columns.Clear();
foreach (RecordField fld in rdr.Fields)
{
grid.ColumnModel.Columns.Add(new Column() {DataIndex= fld.Name, Header = fld.Name});
}
grid.Store.Add(store);
store.DataSource = dtDiff; //start here.
store.DataBind();
store.AutoLoadParams.Add(new Ext.Net.Parameter { Name = "start", Value = "0", Mode = ParameterMode.Raw });
store.AutoLoadParams.Add(new Ext.Net.Parameter { Name = "limit", Value = "20", Mode = ParameterMode.Raw });
grid.SelectionModel.Add(new RowSelectionModel());
grid.ID = dtDiff.TableName;
grid.ClientIDMode = ClientIDMode.Static;
//grid.AddTo(this.pnlCompareData,true);
//pnlCompareData.Items.Add(grid);
pnlCompareData.Items.Add(grid);
//pnlCompareData.Render();
//pnlCompareData.DoLayout();
}