Question

Im trying to create a Gridpanel from codebehind with varying Columns. No clue why it doesn't work, I'm not getting an error just the Columns won't appear.

Ive got a Store and a Gridpanel in Markup Code:

<ext:Store ID="Store_X" runat="server" AutoLoad="false" OnReadData="Store_X_refresh">
    <Proxy>
        <ext:PageProxy />
    </Proxy>

</ext:Store>
[...]
<ext:GridPanel runat="server" ID="gp_center" Region="Center" StoreID="Store_X" Title="X Tracking" >
    <ColumnModel >
            <Columns>
                <ext:RowNumbererColumn ID="RowNumbererColumn2" runat="server" />

            </Columns>
        </ColumnModel>
    </ext:GridPanel>

In my Store_X_refresh i have a List<KeyValuePair<string, int>> fieldStringList = new List<KeyValuePair<string, int>>(); into wich i load what Columns I want (depending on options selected). Before I access Database im doing this:

Ext.Net.Model newModel = new Ext.Net.Model();
            foreach (var item in fieldStringList)
            {
                newModel.Fields.Add(new Ext.Net.ModelField() { Name = item.Key });
                gp_center.ColumnModel.Columns.Add(new Ext.Net.Column() { DataIndex = item.Key, ID = "col_" + item.Key, Text = item.Key, Width = item.Value });
            }
            Store_X.Model.Add(newModel);

when I debug it, the Models get the right Data but the Gridpanel on UI doesn't have the Columns... When I put Columns in store/columnmodel manually in markupcode the Gridgets correct Data so its not about some .DataBind() nor my DB-functionality

Was it helpful?

Solution

If you are changing ColumnModel of a Grid during a DirectEvent you should Reconfigure it. Please, look at this example: http://examples.ext.net/#/GridPanel/Data_Presentation/Grid_and_Store_Reconfigure/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top