PDA

View Full Version : ext js with java



ramesan.rakesh
1 Dec 2009, 11:12 PM
hai i am using ext js to populate panel grid..reading json object from a java bean...
the error i get is proxy.load is not a method ..
any clues ..
here is my code....help appreciated..


Ext.onReady(function(){

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());


var eRecord = Ext.data.Record.create({
fields: [
{name: 'company'},
{name: 'price', type: 'string'},
{name: 'change', type: 'string'},
{name: 'pctChange', type: 'string'},
{name: 'lastChange', type: 'string'}
]
});

// manually load local data


var eReader = new Ext.data.JsonReader({id:"desc"}, eRecord);

var ds = new Ext.data.Store(

{
proxy:new Ext.ux.data.DwrProxy(

{
api : {read : WFManualTaskBean.Test
},
listeners:{"beforeload":function (dataProxy, params)
{
params[dataProxy.loadArgsKey] = ["ADMINISTRATION",'ADMINCTRL',"loadView"];
}
}
}
)
, reader:eReader
}
);
ds.load();

function change(val){
if(val > 0){
return '<span style="color:green;">' + val + '</span>';
}else if(val < 0){
return '<span style="color:red;">' + val + '</span>';
}
return val;
}

/**
* Custom function used for column renderer
* @param {Object} val
*/
function pctChange(val){
if(val > 0){
return '<span style="color:green;">' + val + '%</span>';
}else if(val < 0){
return '<span style="color:red;">' + val + '%</span>';
}
return val;
}



function trimmer(value,p,r)
{
if(value.length>10)
{

return String.format("{0}{1}",(value.length>10?value.substring(0,10):value),'...')
//return (value.substring(0, 10)+'..');
}
}
// create the Grid
var grid = new Ext.grid.GridPanel({
store: ds,
columns: [
{id:'company',header: 'Company', width: 160, sortable: true, dataIndex: 'company',renderer:trimmer},
{header: 'Price', width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
{header: 'Change', width: 75, sortable: true, renderer: change, dataIndex: 'change'},
{header: '% Change', width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'},
{header: 'Last Updated', width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
stripeRows: true,
singleSelect: false,
autoExpandColumn: 'company',
height: 350,
width: 600,
title: 'Array Grid',
// config options for stateful behavior
stateful: true,
stateId: 'grid',

});


// render the grid to the specified div in the page
grid.render('grid-example');
});

jburnhams
3 Dec 2009, 12:36 AM
You should ask this in the Ext Js help form, this is for Gxt

ramesan.rakesh
3 Dec 2009, 11:40 PM
thanks but was a version problem ...the function proxy.load is not avaliable in ext2.. but 3..