PDA

View Full Version : grids and forms



helavissa
18 Nov 2010, 12:21 AM
Hi,

I've never used Ext forms, the problem I have seems to be simple, but I can't figure it out.

I have a grid with checkboxes on the left to select rows and submit button in the bottom.



var sm = new Ext.grid.CheckboxSelectionModel({});

var grid = new Ext.grid.GridPanel({
store: store,
columns: [
sm,
{id:'company',header: 'Company', width: 160, sortable: true, dataIndex: 'company'},
{header: 'Price', width: 75, sortable: true, dataIndex: 'price'},
{header: 'Change', width: 75, sortable: true, dataIndex: 'change'},
{header: '% Change', width: 75, sortable: true, dataIndex: 'pctChange'},
{header: 'Last Updated', width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
sm: sm,
stripeRows: true,
autoExpandColumn: 'company',
height: 350,
width: '100%',
title: 'Array Grid',
stateful: true,
stateId: 'grid',
enableColumnResize : false,
bbar: [
{
xtype: 'button',
text: 'submit',
listeners: {
'click': {
scope: this,
fn: function(src, e) {
// ???
}
}
}
}
]
});

All I want to do is to post data from the selection model to a certain link when user clicks submit, I don't even know if need to create form for that.

laurentParis
18 Nov 2010, 1:27 AM
I suggest


scope: grid,
fn: function(src, e) {
var sel=grid.getSelectionModel().getSelections();
/* transform your datas */
sel = Ext.encode(sel);
/* send your datas */
Ext.Ajax.request({
url : 'http://yourUrl....',
method: 'post',
params: {
datas: sel
}
});
}

Niugeo
15 Dec 2010, 2:12 AM
Hi all,
My problem is quite similar to the one discussed here.
I've a botton in each row on the last column of my grid, and when I click the button I would like to send two the data of the record( their fieldname are 'Surname' and 'Name') with POST method to a external .php file.
Can I insert the Ext.Ajax.request inside the handlers of the column containing the button?
Do I have to encode the data from the grid.getStore()??I ask this because it looks like the metod grid.getStore.getAt(rowIndex).get('Surname') reply with an Object instead of a String.
I'm using a data.Store, how can I decode the data?
Any help will be appreciate?