PDA

View Full Version : apply renderer to store not just grid



wasima
11 Mar 2012, 2:42 AM
I have a grid that takes data from store, i have a date field in grid , i have given that column as date ,renderer: Ext.util.Format.dateRenderer('d/m/Y') i am reading the grid data to export its contents to excel file the issue is reading data from grid is nothing but reading data from store like grid.getStore().each(function(rec) but when i export date filed is still not in format as specified by renderer ....it continues to be in format as it received data from servlet.....how do i make renderer to be applicable to store as well not just the grid....?

chramer
11 Mar 2012, 3:56 AM
you should have this in your model or store:

fields :
[
{name : 'SOMEDATE', type : 'date', dateFormat : 'd/m/Y'},
]

wasima
11 Mar 2012, 9:36 PM
sorry this didn't work :(
I gave the same as you mentioned above in the fields in model ......now no data is getting displayed under date field in grid.......is it a mapping issue? 'name' above is what ? i have fields like ..
,fields: [ 'name','type','serialNum','partNum','manufacturer', 'installedOn'] i modified it as..
,fields: [ 'name','type','serialNum','partNum','manufacturer',{name : 'installedOn', type : 'date', dateFormat : 'd/m/Y'}] now i get no data displayed under 'installedOn' column. can u help me ?

chramer
11 Mar 2012, 11:40 PM
add this code to the fields :

{name : 'installedOn', type : 'date', dateFormat : 'c'}

and this to the columns :

{header : 'Installed On', dataIndex: 'installedOn', xtype : 'datecolumn', format : 'd/m/Y'}

skirtle
12 Mar 2012, 1:39 AM
You can't put a renderer on a store as such.

Really it's the responsibility of the export-to-Excel code to handle these rendering details. However, if you always want to display the data in the same way then perhaps you could alter the way you're storing the data in the store. Try using a convert function on your field to convert the data into the right form in the store instead of using renderers.