[OPEN] [#756] Grid - Locked Columns not locked when configured after load

  1. #1

    [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:

    <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 8:28 PM. Reason: [OPEN] [#756]
  2. #2
    Hi @glenh,

    Please try to set EnableLocking="true" for the GridPanel.
    http://docs.sencha.com/extjs/4.2.1/#...-enableLocking

    Locking should be enabled initially. Just if there is a locked column in an initial config, locking is enabled automatically.
  3. #3
    Hi Danil

    Unfortunately setting EnableLocking on the Grid throws an error if there are no defined Columns (on load).

    No mind, I can live with the work around but thought it would be best to report it anyway.

    Thanks
    Glen
  4. #4
    Thank you for reporting that!

    Created an Issue to track the defect.
    https://github.com/extnet/Ext.NET/issues/756

Similar Threads

  1. Replies: 3
    Last Post: Feb 04, 2015, 6:08 PM
  2. [CLOSED] Gridpanel columns move with locked = true
    By PoloTheMonk in forum 2.x Premium Help
    Replies: 10
    Last Post: Aug 12, 2014, 3:41 PM
  3. Replies: 6
    Last Post: Apr 23, 2013, 3:20 PM
  4. [CLOSED] Gropingview with locked columns almost working
    By feanor91 in forum 2.x Premium Help
    Replies: 5
    Last Post: Apr 25, 2012, 3:36 PM
  5. Replies: 1
    Last Post: May 12, 2010, 5:41 PM

Posting Permissions