PDA

View Full Version : [FIXED-660] Invalid metaData.style in renderer



Tawez
24 Feb 2010, 8:29 AM
In renderer's metaData, all fields but style are OK.
metaData.style has value from previous cell.
That's because of (IMHO) invalid code order in Ext.grid.GridView.doRender()


doRender : function(cs, rs, ds, startRow, colCount, stripe){
...
for(var j = 0, len = rs.length; j < len; j++){
...
for(var i = 0; i < colCount; i++){
...
p.value = c.renderer.call(c.scope, r.data[c.name], p, r, rowIndex, i, ds);
p.style = c.style;
...
}
...
}
...
}

FIX: set value to p.style before call to renderer

If it is not a bug and there is a reason to doing it this way, just give me hint ;)

Jamie Avins
24 Feb 2010, 9:19 AM
Need a test case for your issue to open this as a bug.

Tawez
25 Feb 2010, 3:09 AM
Sure, srr /:)
Let's do it the right way ;)

Ext version tested:

Ext 3.0.0
Ext 3.1.0
Ext 3.1.1


Description:

In renderer's metaData, all fields but style are OK.
It's OS/browser independent


Test Case:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">

<head>
<title>renderer test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/lib/ext300/resources/css/ext-all.css" />
<script type="text/javascript" src="/lib/ext300/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="/lib/ext300/ext-all-debug.js"></script>

<script type="text/javascript">
Ext.BLANK_IMAGE_URL = '/lib/ext300/resources/images/default/s.gif';

Ext.onReady(function(){
var myRenderer = function (value, metaData, record, row, col, store) {
return String.format('({0},{1})[{2}] {3}', row, col, value, metaData.style);
};

var myData = [
[10, 11, 12, 13, 14, 15]
,[20, 21, 22, 23, 24, 25]
,[30, 31, 32, 33, 34, 35]
];

var myStore = new Ext.data.ArrayStore({
autoDestroy: true
,storeId: 'myStore'
,idIndex: 0
,fields: [
'id'
,'first'
,'second'
,'third'
,'fourth'
,'fifth'
]
,data: myData
});

var myGrid = new Ext.grid.GridPanel({
renderTo: 'myGrid'
,store: myStore
,columns: [
{id: 'id', header: 'ID', dataIndex: 'id', width: 100, renderer: myRenderer}
,{header: '1st', dataIndex: 'first', width: 110, renderer: myRenderer}
,{header: '2nd', dataIndex: 'second', width: 120, renderer: myRenderer}
,{header: '3rd', dataIndex: 'third', width: 130, renderer: myRenderer}
,{header: '4th', dataIndex: 'fourth', width: 140, renderer: myRenderer}
,{header: '5th', dataIndex: 'fifth', width: 150, renderer: myRenderer}
]
,width: 800
,height: 150
,frame: true
,title: 'Renderer test'
});
}); //end onReady
</script>
</head>

<body style="padding:20px;">
<div id="myGrid"></div>
</body>
</html>
The result that occurs:

metaData.style data is shifted +1 in each grid cell and undefined in first cell


Possible fix:

In Ext.grid.GridView.doRender(): set value to p.style before call to renderer

Jamie Avins
5 Mar 2010, 1:08 PM
This is fixed in svn for 3.2.