PDA

View Full Version : How to specify the render fonction by metabada



tdikarim
21 Apr 2011, 4:21 AM
Hi,

I use metadata from server for populate a grid
How can I specify the renderer function by column and / or by row ?

thanks to All

friend
21 Apr 2011, 5:28 AM
Here are several custom renderers which get applied to a grid's columns:


/*
* Render child Product object's name.
*/
function renderProduct(value, metaData, record, rowIndex, colIndex, store) {
return value.productName;
};

/**
* Renders a Status Code Object's name.
*/
function renderStatusCode(value, metaData, record, rowIndex, colIndex, store) {
return value.description;
};

/**
* Number renderer for Scheduled qty.
*/
var renderNumber = Ext.util.Format.numberRenderer('999,999,999');


var gridConfig = {
columns: [
{header: 'Order No.', dataIndex: 'mfgOrderNo', sortable: true, width: 90},
{header: 'Promise Date', dataIndex: 'promiseDate', sortable: true, width: 90, renderer: Ext.util.Format.dateRenderer('m/d/y')},
{header: 'Sched. Qty.', dataIndex: 'scheduledQty', align: 'right', sortable: true, width: 90, renderer: renderNumber},
{header: 'Product', dataIndex: 'product', sortable: true, width: 220, renderer: renderProduct},
{header: 'Product ID', dataIndex: 'productId', width: 50, hidden: true}, // hidden
{header: 'BOM Version', dataIndex: 'bomVersion', width: 100},
{header: 'Status', dataIndex: 'statusCode', sortable: true, width: 150, renderer: renderStatusCode},
{header: 'Status ID', dataIndex: 'statusCodeId', width: 50, hidden: true}, // hidden
{header: 'Unique ID', dataIndex: 'mfgOrderId', align: 'right', sortable: true, width: 80}
],
<...>
};

tdikarim
21 Apr 2011, 5:39 AM
In my case the grid is configured by a JSON from the server (metadata)
I try to apply the renderer property but nothing happens

tdikarim
21 Apr 2011, 3:06 PM
Any comments from the Ext-Team please