Feb 23, 2011, 8:32 AM
[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
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.