RSS

Querying in ExtJs Json Store

22 Jul

This deals with queries similar to sql like getting number of records from a json store based on conditions, getting a record etc,

Ex: To get the no of records with title “xxx” from the below json data store,

var dataList = {
    “data”: [{
            “id”: 1,            
        “title”:”xxx”,                
            },
        {
            “id”: 2,            
        “title”:”yyy”        
            }]
};

var sampleStore = new Ext.data.JsonStore({
                id: ‘sampleStore’,
                ..

                data:dataList,
                ..
            });

Use this,

sampleStore.query(“title”, “xxx”)).getCount()

 

To get the record by id,

sampleStore.getById(id)

 

To get the record at particular index,

sampleStore.getAt(index)

 

 
2 Comments

Posted by on July 22, 2011 in Ext JS

 

Tags: , , ,

2 responses to “Querying in ExtJs Json Store

  1. Steve c

    February 8, 2012 at 12:05 am

    doesn’t the query line have an extra bracket?

     
  2. Creators

    February 15, 2012 at 11:44 am

    which line?

     

Leave a comment