I'm programming a dynamic Grid. I use PHP's json_enode() to pass the ColumnModel options. Now, I would also like to pass a renderer. My definition in PHP looks something along the lines of:
PHP Code:
$colModel = array(
array(
'id' => 'icon',
'header' => 'Icon',
'width' => 40,
'dataIndex' => 'icon',
'renderer' => renderIcon, // where renderIcon would be the rendering function
),
array(
'id' => 'nr',
'header' => 'Nr',
'dataIndex' => 'nr',
'width' => 200,
),
...
);
json_encode( $colModel );
On the client side I get the data from PHP with a Ext.data.Connection. This gets passed to the grid's ColumnModel:
PHP Code:
...
var cm = Ext.decode( response.responseText );
var colModel = new Ext.grid.ColumnModel(cm);
My problem is, that PHP's json_encode() converts the value of "renderer" to a string:
Code:
...
{"id":"icon","header":"Icon","width":40,"dataIndex":"icon","renderer":"renderIcon"}
...
In the column definition, however, it needs to appear WITHOUT quotes. Does anyone have an idea how this can be done?
Thanks!!