Feb 03, 2012, 3:24 AM
Adding row to grid
Please see the code below on EXT.net 1.2. We have a listener that generates a new row when a button is pressed. However, we see an error message "Microsoft JScript runtime error: 'data' is null or not an object". the error occurs in the ext code when the store.add is pressed. store.insert works fine.
The error is since records is a list of two and the first is undefined. so data cannot be called. The defect is that it should be an array of one, not two.
The error is since records is a list of two and the first is undefined. so data cannot be called. The defect is that it should be an array of one, not two.
doRender : function(columns, records, store, startRow, colCount, stripe) {
var templates = this.templates,
cellTemplate = templates.cell,
rowTemplate = templates.row,
last = colCount - 1,
tstyle = 'width:' + this.getTotalWidth() + ';',
rowBuffer = [],
colBuffer = [],
rowParams = {tstyle: tstyle},
meta = {},
len = records.length,
alt,
column,
record, i, j, rowIndex;
for (j = 0; j < len; j++) {
record = records[j];
colBuffer = [];
rowIndex = j + startRow;
for (i = 0; i < colCount; i++) {
column = columns[i];
meta.id = column.id;
meta.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
meta.attr = meta.cellAttr = '';
meta.style = column.style;
ERROR LINE meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
if (Ext.isEmpty(meta.value)) {
meta.value = '*';
}
<Columns>
<ext:Column Header="Id" ColumnID="id" DataIndex="id" Width="35" Hidden="true"/>
<ext:CommandColumn Width="24">
<Commands>
<ext:GridCommand CommandName="AddRow" Icon="Add">
<ToolTip Text="Add New Row" />
</ext:GridCommand>
</Commands>
</ext:CommandColumn>
<Listeners>
<Command Handler="generateNewRow(command, record.data, GridPanelTimecard, record);" />
</Listeners>
Last edited by geoffrey.mcgill; Feb 03, 2012 at 4:03 AM.