Search code examples
arraysextjsstore

extjs array reader


I'm trying to create a data store with an array reader. in each of the record, there is an array of fields. However, I only need some of the fields in the record. How can I setup the array reader so that only part of the record is mapped to the data store?


Solution

  • For each field in the reader, just add a 'mapping' item and set it equal to the index of the item in the array it is for. eg:

    var arrData = [
        ['Col 1', 'Col 2', 'Col 3']
        ['Col 1', 'Col 2', 'Col 3']
        ['Col 1', 'Col 2', 'Col 3']
    ];
    var reader = new Ext.data.ArrayReader({}, [
        {name: 'First Column', mapping: 0},
        {name: 'Third Column', mapping: 2},
    ]);
    

    This will exclude the 2nd column (zero based index)