View Full Version : ColumnModel renderer

29 Jun 2009, 1:34 PM
I want to render "Stock" column using the value of column "Threshold".

var PcolModel = new Ext.grid.ColumnModel([
{id:'ProductName',header: "Name", width:125, sortable: true, locked:false, dataIndex: 'ProductName'},
{header: "Code", width: 50, sortable: true, dataIndex: 'ProductCode'},
{header: "Price", width: 70, sortable: true, dataIndex: 'Price'},
{header: "ShelfLife", width: 75, sortable: true, renderer: amt, dataIndex: 'ShelfLife'},
{header: "Stock", width: 75, sortable: true, renderer: searchPRend, dataIndex: 'CurrentQuantity'},
{header: "Threshold", width: 25, sortable: true, dataIndex: 'Threshold'}

function searchPRend(val){
var fieldName = PcolModel.getDataIndex(6);
var fieldValue = currentRecord.get(fieldName);

val= '<b><span style="color:#0000FF; font-size:20px;">'+val+'</span></b>';
}else if(parseInt(val)<=parseInt(fieldValue)){
val= '<b><span style="color:#FF0000; font-size:20px;">'+val+'</span></b>';
return val;

I am getting the following error:

this.config[col] is undefined
getDataIndex()(6)ext-all-debug.js (line 34476)
searchPRend("6")salestab.js (line 3791)
doRender()([Object name=ProductName id=ProductName style=width:118px;, Object name=ProductCode id=1 style=width:46px;, Object name=Price id=2 style=width:65px;, 3 more... 0=Object 1=Object 2=Object 3=Object 4=Object 5=Object], [Object id=1531 data=Object json=Object store=Object, Object id=1532 data=Object json=Object store=Object, Object id=1533 data=Object json=Object store=Object, 1 more... 0=Object 1=Object 2=Object 3=Object], Object data=Object baseParams=Object paramNames=Object, 0, 6, false)ext-all-debug.js (line 32435)
renderRows()(0, 3)ext-all-debug.js (line 32976)
renderBody()()ext-all-debug.js (line 32981)
refresh()(undefined)ext-all-debug.js (line 33006)
onDataChange()()ext-all-debug.js (line 33161)
fire()()ext-all-debug.js (line 1515)
fireEvent()()ext-all-debug.js (line 1202)
loadRecords()(Object success=true records=[4] totalRecords=4, Object, true)ext-all-debug.js (line 11213)
loadResponse()(Object params=Object request=Object reader=Object, true, Object tId=3 status=200 statusText=OK)ext-all-debug.js (line 11717)
apply()(function(), Object events=Object conn=Object useAjax=true, [Object params=Object request=Object reader=Object, true, Object tId=3 status=200 statusText=OK 0=Object 1=true 2=Object], undefined)ext-base.js (line 9)
handleResponse()(Object tId=3 status=200 statusText=OK)ext-all-debug.js (line 5483)
apply()(Object conn=XMLHttpRequest tId=3, Object scope=Object argument=Object timeout=30000, undefined)ext-base.js (line 9)
apply()()ext-base.js (line 9)

return this.config[col].dataIndex;

Please help.

29 Jun 2009, 1:56 PM
Index will begin at zero (0), you only have 6 columns, not 7 (6+1).

Also, you should look at the docs for renderer (http://extjs.com/deploy/ext-3.0-rc2/docs/?class=Ext.grid.Column&member=renderer) and convert (http://extjs.com/deploy/ext-3.0-rc2/docs/?class=Ext.data.Field&member=convert) to provide some inspiration how you might properly use a renderer (and all of its arguments) or utilize the convert function.

29 Jun 2009, 1:57 PM
Note, look at the 3.x docs in my signature, they are more informative.

30 Jun 2009, 4:13 AM
thanx mjlecomte, i got the solution...