[CLOSED] Adding a new Store Record - Not a Record object
Hi,
I'm dynamically adding a record to the Store using the new C# AddRecord function IDictionary<string, string> recordData = new Dictionary<string, string>();
Code:
recordData.Add("id", highId);
recordData.Add("parentId", this.parentId.ToString());
recordData.Add("recordTypeId", ((int)this.recordType).ToString());
recordData.Add("addressTitle", addressTitle.Text);
recordData.Add("addressNameNumber", addressNameNumber.Text);
recordData.Add("addressStreet1", addressStreet1.Text);
recordData.Add("addressStreet2", addressStreet2.Text);
recordData.Add("addressTown", addressTown.Text);
recordData.Add("addressCountyState", addressCounty.Text);
recordData.Add("addressCodeZip", addressCodeZip.Text);
recordData.Add("addressCountry", addressCountry.Text);
addressStore.AddRecord(recordData);
If I then look at the DataStore in FireBug, my original records (from the DataBind) are all Record Objects. The new record is an array. This means that when I attempt to get the modified data, Ext.encode will not work on the record.
Is there any way in which AddRecord can add a Record object to the store rather than an array? It's making it very hard to get the required data out to pass back to the system for actioning.
Cheers
Steve
RE: [CLOSED] Adding a new Store Record - Not a Record object
Hi,
I am not sure that understood you. When you use AddRecord the function create a real record object from values and add it to the store (because we can't add to the store something else).
Can you provide more details what is wrong?
RE: [CLOSED] Adding a new Store Record - Not a Record object
Hi Vladimir,
It appears that AddRecord does not add a real Record object to the store. Here's the process.
I have a JsonStore.
Populate this from a DataTable on Form Load.
I have two record objects in the Store object.
Code:
store.items[0].data is an object
store.items[1].data is an object
I create a new record, which gets added via AddRecord
Code:
store.items[2].data is an array, not an object.
The images attached show you the difference. Because items[2].data is an array, it isn't processed in the same way by Ext.encode as
Code:
items[0].data and items[1].data.
Hopefully this helps make things clear.
Cheers
Steve
RE: [CLOSED] Adding a new Store Record - Not a Record object
Hi,
1. Store has no items collection. It has 'data' collection which contains records. So, to get data object of first record you need
Code:
Store1.data.items[0].data
*
2. I don't see any difference between your images which shows any problem (both images show two records and I don't see third record)
I tested AddRecord function and it add correct record which has correct data object
May be you need show example which demontrate the problem
RE: [CLOSED] Adding a new Store Record - Not a Record object
Sorry Vladimir, I uploaded the incorrect second image. Take a look at this one. You can plainly see that the Data object is not a Record Object, it's a simple array. This is the record which was added to the store by AddRecord.
If you look at the first image, you can see that the data element of record one is an object. Does this make things more clear?
Thanks
Steve
RE: [CLOSED] Adding a new Store Record - Not a Record object
Hi,
Thanks for image. Fixed. Please update*