Mar 11, 2015, 3:14 AM
[OPEN] [#756] Grid - Locked Columns not locked when configured after load
Hi
I have a dynamic gird that I am loading after selecting a CSV file. i.e. There are no modelfields in the store and there are no columns in the grid when the form is first loaded. Once the user has selected a CSV file. I dynamically set ModelFields and Grid columns in code behind based on the imported data.
I can get this to work but I want to lock some columns and I find that it's not working when setting the locked column dynamically.
I have added some code that shows this issue:
I have overcome this with a workaround but I don't really want the extra column in the grid....the workaround is by adding a hidden column set to locked in the markup
Thanks
Glen
I have a dynamic gird that I am loading after selecting a CSV file. i.e. There are no modelfields in the store and there are no columns in the grid when the form is first loaded. Once the user has selected a CSV file. I dynamically set ModelFields and Grid columns in code behind based on the imported data.
I can get this to work but I want to lock some columns and I find that it's not working when setting the locked column dynamically.
I have added some code that shows this issue:
<ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" ScriptMode="Debug"></ext:ResourceManager>
<ext:GridPanel ID="grid" runat="server" Height="300" Width="300">
<Store>
<ext:Store runat="server" ID="store" AutoLoad="False">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column1" runat="server" Locked="true" Hidden="true"></ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
<ext:Button runat="server" Text="Load">
<DirectEvents>
<Click OnEvent="DoLoad"></Click>
</DirectEvents>
</ext:Button>
protected void DoLoad(object sender, DirectEventArgs e)
{
Store store = this.store;
var modelField1 = new ModelField("Col1", ModelFieldType.Auto);
this.store.AddField(modelField1);
var modelField2 = new ModelField("Col2", ModelFieldType.Auto);
this.store.AddField(modelField2);
// this column is locked
Column column1 = new Column();
column1.DataIndex = modelField1.Name;
column1.Text = modelField1.Name;
column1.Locked = true;
this.grid.AddColumn(column1);
// this column is not locked
Column column2 = new Column();
column2.DataIndex = modelField2.Name;
column2.Text = modelField2.Name;
this.grid.AddColumn(column2);
}
After running this there are two columns in the grid but the first column is not locked.I have overcome this with a workaround but I don't really want the extra column in the grid....the workaround is by adding a hidden column set to locked in the markup
<ColumnModel>
<Columns>
<ext:Column runat="server" Locked="true" Hidden="true"></ext:Column>
</Columns>
</ColumnModel>
It would be good if you could let me know what I should do to make this work?Thanks
Glen
Last edited by Daniil; Mar 11, 2015 at 7:28 PM.
Reason: [OPEN] [#756]