[CLOSED] ReaderID in ArrayReader

  1. #1

    [CLOSED] ReaderID in ArrayReader

    Hello,

    I have the store defined like this:

    <ext:Store ID="store" runat="server">
        <Reader>
            <ext:ArrayReader ReaderID="Id" >
                <Fields>
                    <ext:RecordField Mapping="Name" />
                    <ext:RecordField Name="Id" Mapping="Id" Type="Int" />
                </Fields>
            </ext:ArrayReader>
        </Reader>
    </ext:Store>
    I use Mapping attributes, because Name attributes don't work unlike in JsonReader.

    Anyway, the above definition translates to this

    new Ext.ux.data.PagingStore({
      id: "filter_store",
      ajaxEventConfig: {
      formProxyArg: "mainForm"
    },
      reader: new Ext.data.ArrayReader({
      id: "1",
      fields: [{
      mapping: "Name",
      name: "Name"
    },{
      type: "int",
      mapping: "Id",
      name: "Id"
    }]
    })
    As you can see, ArrayReader.id is set to "1" which in my opinion should be "Id". With "1" store.getById() method just doesn't work, as "1" is no property in data.

    Regards,
    Tadeusz

  2. #2

    RE: [CLOSED] ReaderID in ArrayReader

    Hi,

    You can't mapping values in an array by name because an array doesn't contain names of properpties (list of values only). Therefore mapping allows by index only

    var Employee = Ext.data.Record.create([
        {name: 'name', mapping: 1},         // "mapping" only needed if an "id" field is present which
        {name: 'occupation', mapping: 2}    // precludes using the ordinal position as the index.
    ]);
    
    var myReader = new Ext.data.ArrayReader({
        id: 0                     // The subscript within row Array that provides an ID for the Record (optional)
    }, Employee);
    This would consume an Array like this:

    [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
  3. #3

    RE: [CLOSED] ReaderID in ArrayReader

    Thank you for the explanation - it's all clear now.

    Tadeusz

Similar Threads

  1. [CLOSED] Using ArrayReader with DataView XTemplates
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 27, 2012, 6:12 PM
  2. [CLOSED] ArrayReader: databind
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 03, 2010, 7:36 PM
  3. Replies: 2
    Last Post: May 26, 2010, 11:58 PM
  4. [CLOSED] [1.0] Store ReaderID property
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 18, 2009, 1:23 PM
  5. GridPanel - Select Row Other than by ReaderID
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: Jun 05, 2009, 12:33 AM

Posting Permissions