View Full Version : Getting data out of a store and using it for further processing

6 Jun 2014, 8:12 AM
Dear All, I am a newbie and have been learning EXT-js 4 for a month already. I am new to most web application technologies like Ajax for instance. I am creating my first Ext app and am trying to use MVC architecture. I have a user input form that inputs certain data it is any concentration for a chemical. I have certain data stored on the server in a json file i want to load that data into a store and compare if the values entered by the user fall into any of the ranges defined in that data. let me give you some code


"level": 3,
"value": 1.5,
"level": 2,
"value": 0.15,
"level": 1,
"value": 0.05,

Model (chem.Limits)

Ext.define('PLUSES.model.chem.Limits', {
extend: 'Ext.data.Model',
fields: [
{name: 'level', type: 'int'},
{name: 'value', type: 'int'},
{name: 'name', type: 'string'}


// The controller is too lengthy and so i am putting only the relevant code here
// I create an instance of the model and load the data from the json file into the store when i display it in
//grid it works fine but i want to use this data and compare it to certain other values... how to do that I
//have tried many different suggestion in different forums the whole day and now i am fed up and
//thought i should ask this again (i know it has been asked many times and answered many times).

var limitstore = Ext.create('Ext.data.Store', {
model: 'PLUSES.model.chem.Limits',
autoLoad: true,
proxy: {
type: 'ajax',
url : 'resources/AdviceCenter/Acrolein/limits.json',
reader: {
type: 'json',
root: 'limits'

// The above line gives me some data in the console, I can not find the actual data anywhere.
// The following line gives me 0

But it does display data in grid panel for sure :s
Any help would be appreciated. Okay I was playing around with the Ext.data.Store methods and realized that if i add the following lines I can some how access the store values

scope: this,
callback: function(records, operation, success) {
// the operation object
// contains all of the details of the load operation

This returns 3 in the console... Do I need to write all the logic in the callback function (does not sound right to me =;)... because if i write the console.log(store.getTotalCount()); line "after" the store.load it gives me 0 again

Scott Mildenberger
6 Jun 2014, 11:35 AM
On whatever event you want this to happen you can get an instance of the store and then use queryBy() to find matching records like

var values = dsTrans.queryBy(function(record) {
return record.get('GROUPER') === Invoice;

for (var i = 0, len = values.length; i < len; i++) {
var description = values.getAt(i).get('KDIDES'),

dsTrans above is my store. You write the function to determine if a record matches the criteria. It returns an array of matching records.

24 Jun 2014, 7:38 AM
Thanks a lot i faced a lot of problems but this method definitely works guys