PDA

View Full Version : Need Help for Read Grid data in to server Request !



ravi123
4 Jun 2008, 4:59 AM
Need Help for Read Grid data in to server Request

my code is
/*
* Ext JS Library 2.1
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
var PresidentsDataStore; // this will be our datastore
var PresidentsColumnModel; // this will be our columnmodel
var PresidentListingEditorGrid;
var PresidentListingWindow;


Ext.onReady(function(){

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

var myData = [
['1','']
];


var LocationBlank = Ext.data.Record.create([
{name: 'intLoctionID', type: 'int'},
{name: 'vchCity', type: 'string'}
]);

// create the data store
PresidentsDataStore = new Ext.data.SimpleStore({
fields: [
{name: 'intLoctionID'},
{name: 'vchCity'}
]
});

PresidentsDataStore.loadData(myData);


// Create Coloum Mode
PresidentsColumnModel=new Ext.grid.ColumnModel(
[
{
header: '#',
dataIndex: 'intLoctionID',
width: 15
},
{
header: 'City',
dataIndex: 'vchCity',
width: 150,
editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 20,
maskRe: /([a-zA-Z0-9\s]+)$/
})
}]
);

PresidentsColumnModel.defaultSortable= true;


// create the Grid
PresidentListingEditorGrid = new Ext.grid.EditorGridPanel({
id: 'PresidentListingEditorGrid',
store: PresidentsDataStore, // the datastore is defined here
cm: PresidentsColumnModel, // the columnmodel is defined here
enableColLock:false,
clicksToEdit:1,
height:200,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
tbar:[{
text:'Add Location',
tooltip:'Add a new Location',
iconCls:'add',
handler : function(){
var p = new LocationBlank({
intLoctionID:PresidentsDataStore.getCount()+1,
vchCity:''
});

PresidentListingEditorGrid.stopEditing();
// Ext.MessageBox.alert('Message',PresidentsDataStore.getCount());
PresidentsDataStore.insert(PresidentsDataStore.getCount(), p);
PresidentListingEditorGrid.startEditing(1, 0);

}
},'-',{
text:'Remove LocationAccount',
tooltip:'Remove the selected bank account',
iconCls:'remove',
handler: handleDelete //what happens when user clicks on it
}]
});




function handleDelete() {
var selectedKeys = PresidentListingEditorGrid.selModel.selections.keys; //returns array of selected rows ids only
if(selectedKeys.length > 0) {

var row=PresidentListingEditorGrid.getSelectionModel().getSelected().data['intLoctionID']
PresidentsDataStore.remove(PresidentListingEditorGrid.getSelectionModel().getSelected());
// Ext.MessageBox.alert('Message',row );



}else{
Ext.MessageBox.alert('Message','Please select at least one item to delete');
}
};

PresidentListingEditorGrid.render('gridlocation');

});

i read this grid data from server request i get only end row data value ...
any body help for get all value in server request .
i want to save all data only after save button click.

above code is work fine..

just i need get that gird datas..

mjlecomte
4 Jun 2008, 8:10 AM
I don't understand your problem, have your server send back whatever data you want to show in the grid, if it only shows 1 record, then it's a problem on your server side application.

For more examples check out www.extjs.eu, you might like something like recordform plugin.

Also you're posting in Ext1 forum, but you're obviously using Ext2.

ravi123
4 Jun 2008, 7:56 PM
hi thanks for your reply....

my problem is

i store grid data in SimpleStore in client side for dynamically. Like add and Delete Row.

then after finished i click save button all data can be send to server and saved. before that i dont want to save each and every row.


i am using jsf . onle client side i am using extjs and i dont want to use ajax request.