[CLOSED] Locking Grid and AddColumn

  1. #1

    [CLOSED] Locking Grid and AddColumn

    Hi,

    I need to create my data source fields and grid columns dynamically as the data source has a variable number of columns (days).
    This works fine until I introduce the locking grid view and then a javascript error occurs.

    Please see the code snippets below. This worked fine until the Locking grid view was included.

    The error caught in chrome is Uncaught TypeError: Object [object Object] has no method 'isLocked' which happens in the following code in ext.axd, note the value of cm is null.

    getColumnData : function () {
    
            var cs = [], cm = this.cm, colCount = cm.getColumnCount();
            for (var i = 0; i < colCount; i++) {
                var name = cm.getDataIndex(i);
                cs[i] = {
                    name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
                    renderer : cm.getRenderer(i),
                    id : cm.getColumnId(i),
                    style : this.getColumnStyle(i),
                    locked : cm.isLocked(i)
    
                };
            }
            return cs;
    The ASPX page:

      protected override void OnInit(EventArgs e)
        {
    
            ResourceManager.GetInstance().RegisterIcon(Icon.Note);
    
            var valueIndex = 0;
            foreach (var header in Model.Header)
            {
    
                string fieldName = string.Format("Value_{0}", valueIndex++);
    
                var valueColumn = new NumberColumn
                              {
                                  Header = "Test",
                                  Sortable = false,
                                  Width = 200,
                                  Hideable = false,
                                  DataIndex = fieldName,
                                  Format = "0"
                              };
    
    
                GridPanel1.AddColumn(valueColumn);
    
                var recordField = new RecordField(fieldName, RecordFieldType.Int);
                Store1.AddField(recordField);
    
            }
      <ext:Store runat="server" ID="Store1">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Label">
                        </ext:RecordField>
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
                <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" Layout="Fit" ClicksToEdit="1">
                    <ColumnModel>
                        <Columns>
                            <ext:Column Header="Core Task" DataIndex="Label" Hideable="false" Locked="true">
                            </ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel runat="server">
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <View>
                        <ext:LockingGridView runat="server">
                        </ext:LockingGridView>
                    </View>
                </ext:GridPanel>
    Last edited by geoffrey.mcgill; Feb 06, 2015 at 11:45 PM.
  2. #2
    Hi,

    Please use
    GridPanel1.ColumnModel.Columns.Add(valueColumn);
    and
    Store1.Reader.Reader.Fields.Add(recordField);
    instead of
    GridPanel1.AddColumn(valueColumn);
    and
    Store1.AddField(recordField);
    Please use .AddColumn() and AddField() methods when GridPanel is already rendered, for example, during DirectEvent.

Similar Threads

  1. [CLOSED] Locking Grid with checkboxselection model
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 15, 2012, 6:02 AM
  2. [CLOSED] Locking Grid with RowExpander plugin
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 23, 2011, 2:37 PM
  3. [CLOSED] locking grid view in right side?
    By Suntico in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 19, 2011, 11:38 AM
  4. [CLOSED] Grouping Grid AND Locking Columns...
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 21, 2010, 6:53 PM
  5. [CLOSED] [1.0] Locking Grid View JavaScript Error
    By jskibo in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 01, 2010, 11:09 PM

Posting Permissions