PDA

View Full Version : ddgrid get all id's of dd'd records issue with store.each



nadeemshafi9
27 May 2009, 5:57 AM
Hi guys

i am using sakis dd grids and its nice works perfect my issue is with the platform.

i am trying to get the id's of alll the records in the grid that has been altered eg the destination grid, what is happening is no matter how many records i add the first record always comes up as NAN as its record.data.id in the function store.each, take a look


var newPackageMovies;

Ext.getCmp('grid2').getStore().each(function(r){
newPackageMovies = newPackageMovies + r.data.id + ',';
});

// RESULT: NaN,2,6,8,4,
no matter how many i add its always the first one comming up as NaN


basicaly i need to post this data thats why i am concating a string
thanks for any suggestions

Animal
27 May 2009, 6:03 AM
r.data is the Fields. Is there a Field called "id"?

We need to see your Record def, and your returned JSON.

nadeemshafi9
27 May 2009, 6:09 AM
the json is all good i looked throgh it, the record that shows as NaN is of id 1, yes i have the feild there, they are all correct NaN,2,6,8,4,except for the first one in the grid which is not dragged it was there in the first place.

its there in the JSON the json is box standard i cant put it up here unfortunatly but trust me its box standard and its good generated with zends dojo, it hasent caused probs yet i use it all over with extjs. this is a minute glitch either on my end but maybe on theres.

the id shows up in teh grid just as same as teh others which do get picked up out of the each loop. , thanks in advance


noi matter how many i drag they and all the ones that were in teh gridd before show in the record passed to the each loop, except for that very first one which has id of 1.

Animal
27 May 2009, 6:14 AM
The Record may have an ID of 1. Doesn't mean to say that it has a Field which has teh value 1.

Does it? If you read the docs.

nadeemshafi9
27 May 2009, 6:21 AM
The Record may have an ID of 1. Doesn't mean to say that it has a Field which has teh value 1.

Does it? If you read the docs.

hold on i think there is an issue with my json lol, brb

nadeemshafi9
27 May 2009, 7:01 AM
the json was all good, my colegue deleted some data so i thoght it was wroing, now its all i back in plave the same prob,

this time instead of r.data.id i used r.data.movie_type, still nothing for the first one, when the records are passed to the each loop the first one is empty.
NaN,1,1,1,1,

here is the first line of the firebugged JSON it includes the root and teh identifier both
of which i have set in php zend dojo, i am now just about to change teh identifier because it may cause issues.

{"identifier":"id","items":[{"id":1,"movie_type":1,"order":1,"name":"Rambo - The Fight Continues","source_type"

nadeemshafi9
27 May 2009, 7:02 AM
last line

,"synopsis":null}],"label":"id"}

nadeemshafi9
27 May 2009, 7:05 AM
even if i drag the one that dosent show away into teh other grid (teh one with id = 1) it removes it and then makes teh next one that becomes first in teh grid a NaN on all its feilds

NaN,1,1,1,

nadeemshafi9
27 May 2009, 7:21 AM
its got somthing to do with my concating, this alerts them properly i see the id in teh alert box but not in teh srtring.



Ext.getCmp('grid2').getStore().each(function(r){
alert(r.data.id);
newPackageMovies = newPackageMovies + r.data.id + ',';
});

nadeemshafi9
27 May 2009, 7:25 AM
FIXED



var newPackageMovies;
newPackageMovies = '';
Ext.getCmp('grid2').getStore().each(function(r){
alert(r.data.id);
newPackageMovies = newPackageMovies + r.data.id + ',';
});

nadeemshafi9
27 May 2009, 7:25 AM
how do you take off the leading , ??

Animal
27 May 2009, 7:30 AM
r.data is the fields. The properties are named for the fields, not the original data.

nadeemshafi9
27 May 2009, 8:32 AM
the json was all good, my colegue deleted some data so i thoght it was wroing, now its all i back in plave the same prob,

this time instead of r.data.id i used r.data.movie_type, still nothing for the first one, when the records are passed to the each loop the first one is empty.
NaN,1,1,1,1,

here is the first line of the firebugged JSON it includes the root and teh identifier both
of which i have set in php zend dojo, i am now just about to change teh identifier because it may cause issues.

{"identifier":"id","items":[{"id":1,"movie_type":1,"order":1,"name":"Rambo - The Fight Continues","source_type"


last line

,"synopsis":null}],"label":"id"}


r.data is the fields. The properties are named for the fields, not the original data.


what difference does it make man ? im not with you ???

Animal
27 May 2009, 11:05 AM
The data property of the Record contains properties which are named after the Field names.

In your case, you do have a Field called "id", so it works for you.

Most times, people won't have a Field called "id". They won't be showing it anywhere and it's not changeable, so no Field for it.

In this case, using myRecord.data.id won't work.

nadeemshafi9
27 May 2009, 11:11 AM
so whats teh proepr way of accessing the real data instead of this linkage

Animal
27 May 2009, 11:12 PM
Accessing a Record's id? Hmmmmm....

http://extjs.com/deploy/ext-3.0-rc1.1/docs/?class=Ext.data.Record