PDA

View Full Version : Use the HttpStateProvider user extension



emmy mathew
20 Jul 2010, 9:08 PM
Hi

I used the following code to save the column configurations using HttpStateProvider user extension.The hide/show columns are seen in the post parameters of teststate.php.But when the page is reloaded ,it goes to the default configurations.How to make it a permanent change?

Ext.state.Manager.setProvider(new Ext.ux.state.HttpProvider({
url:'teststate.php'
,user:'tim'
,session:'session'
,id:'1'
,readBaseParams:{cmd:'readState'}
,saveBaseParams:{cmd:'saveState'}
,autoRead:false
// ,logFailure:true
// ,logSuccess:true
}));

Ext.state.Manager.getProvider().initState([{"name":"testgrid","value":"o%3Acolumns%3Da%253Ao%25253Aid%25253Ds%2525253Acompany%25255Ewidth%25253Dn%2525253A376%255Eo%25253Aid%25253Dn%2525253A1%25255Ewidth%25253Dn%2525253A211%25255Ehidden%25253Db%2525253A1%5Esort%3Do%253Afield%253Ds%25253Acompany%255Edirection%253Ds%25253AASC"}]);


Ext.onReady(function(){


var myData = [
['3m Co',71.72],
['Alcoa Inc',29.01],
['Altria Group Inc',83.81],
['American Express Company',52.55],
['American International Group, Inc.',64.13],
['AT&T Inc.',31.61]
];


// create the data store
var store = new Ext.data.ArrayStore({
fields: [
{name: 'company'},
{name: 'price', type: 'float'}
]
});
store.loadData(myData);

// create the Grid
var grid = new Ext.grid.GridPanel({
stateId:'testgrid',
stateful:true,
store: store,
columns: [
{id:'company', header: "Company", width: 400, sortable: true, dataIndex: 'company'},
{header: "Price", width: 75, sortable: true, dataIndex: 'price'}
],
height:350,
width:600,
title:'HTTP Provider Grid'
});
grid.render('grid-example');
});