PDA

View Full Version : Retrieving data from selected row in grid



janixams
9 Jun 2008, 7:33 AM
Hi all,
I have a grid and I take the row ID on rowdblclick event, but I don't know how to identify this ID with the data in the store. I need to know how to retrieve the data from selected row in the grid. :(

I use the fallowing:
[PHP]
var solicitud = {
init :function(){
var datos = [
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente'],
['3m Co','09/01/2008','pendiente']
];
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(datos),
reader: new Ext.data.ArrayReader({}, [
{name: 'nombre'},
{name: 'fecha', type: 'date', dateFormat: 'm/d/Y'},
{name: 'estado'}
])
});
ds.load();

var colModel = new Ext.grid.ColumnModel([
{
id:'nombre',
header: "L

mjlecomte
9 Jun 2008, 3:56 PM
presumably you'll want to make one of those fields a "primary key". So once you have the record you then get that field from the record so you can communicate that "primary key" to your server backend. your example data isn't the best to illustrate your situation.

janixams
9 Jun 2008, 7:45 PM
Thanks for replay and I'm sorry, I have not taken the data from data base yet, I only try with unreal values.

I underestand your way, but...

1- I don't know how to define one of this fields as primary key.
2- I suppose that should take the value of a cell instead of taking the complete row. So, how I can to take the text value contained in a cell?

I really appreciate your help.
Thank you.

mjlecomte
9 Jun 2008, 7:53 PM
I have an example showing all of this in my signature. You've got a good start on it, if nothing else you might scan the posted code to see what's going on. The comments may be more than what you'd need but I'd have to pull out parts here and there to tell you the various parts otherwise.

janixams
10 Jun 2008, 5:45 AM
Hi mjlecomte,
I use Ext 1.1, however your example give me a good idea about grid. I am going to analyse it and I'll post the code when I have any result.
I appreciate your help.
Thanks

mjlecomte
10 Jun 2008, 2:21 PM
I'm not sure, but for your question, I don't think that much has changed from Ext1 in that regard. Please note there is also a couple of screencasts on grids, those are specifically for Ext1.

janixams
10 Jun 2008, 6:19 PM
In fact, your example give me a great idea about grid. I thank you so much.
The problem has been resolved. I use an ID (the same ID I use in the data base) to identify each row and it's work perfectly.
Thank you for your help.