[CLOSED] Adding a new Store Record - Not a Record object

  1. #1

    [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>();

    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

  2. #2

    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?


  3. #3

    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.

    store.items[0].data is an object
    store.items[1].data is an object
    I create a new record, which gets added via AddRecord

    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

    items[0].data and items[1].data.
    Hopefully this helps make things clear.

    Cheers

    Steve
  4. #4

    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
    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
  5. #5

    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

  6. #6

    RE: [CLOSED] Adding a new Store Record - Not a Record object

    Hi,

    Thanks for image. Fixed. Please update*

Similar Threads

  1. Replies: 0
    Last Post: Feb 05, 2012, 12:33 AM
  2. Replies: 16
    Last Post: May 26, 2011, 10:23 PM
  3. [CLOSED] BeforeEdit 'record.data' is null or not an object
    By sharif in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 13, 2010, 2:54 PM
  4. [CLOSED] [1.0] Store adding record
    By state in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Dec 11, 2009, 6:24 PM
  5. Adding one record in a grid
    By nuno_Santos in forum 1.x Help
    Replies: 1
    Last Post: Apr 14, 2009, 5:55 PM

Posting Permissions