PDA

View Full Version : c.setWidth is not a function error.



Jowin
5 Oct 2011, 5:20 AM
Hi,

I created a table grid and created the columns using dynamic functions, i also assigned the row editing plugin to it but i am getting the c.setWidth is not a function error, any suggestions on what i might be doing wrong? this is the create column script..

function createColumn(columnObj,parentGrid){
var dataIndexValue =columnObj.columnName;
var column = Ext.create('Ext.grid.column.Column', {
text: columnObj.columnName,
flex: 1,
dataIndex: dataIndexValue,
field: {
xtype: 'textfield'
}
});
column.getEditor = function (record, defaultField) {
return this.field;
};
parentGrid.headerCt.insert(parentGrid.columns.length, column);
}

skirtle
5 Oct 2011, 8:04 AM
Please use CODE tags when posting code (# button on the editor toolbar).

If you want to change the columns you'll need to use reconfigure():

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.Panel-method-reconfigure

I'd suggest that your createColumn function should return the column rather than injecting it. You can then build up an array of columns and add them using reconfigure().

Jowin
7 Oct 2011, 4:18 AM
Hi,

I tried with the reconfigure method as well, but i am still getting c.setwidth is not a function error? Am i missing something? I passed the object of columns and datastore in the reconfigure string.

skirtle
7 Oct 2011, 8:58 AM
I'd suggest the first thing you should do is to use a debugger to find out what c is when the error occurs. Might reveal all.

Other info that might help:

Exact ExtJS version.

Browsers tested (make sure you've tried multiple).

The full stacktrace, including line numbers, for the error. Make sure you're using a debug build of ExtJS so we get meaningful line numbers.

A complete, minimal test case for the error so that we can reproduce it.