Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:14:28+00:00 2026-06-01T20:14:28+00:00

I have created a model and store in which read in a json file

  • 0

I have created a model and store in which read in a json file as shown below. How can I reference this store in my app.js?

I would like to take the search-list example that Sencha gives here.

And use the store as a drop in replacement for this line in the example:

store = this.getStore();

[Update] Added the reformatted app.js here.

Model:

Ext.define('Sencha.model.Contact', {
    extend: 'Ext.data.Model',

    config: {
        fields: [{
            name: 'firstName',
            type: 'string'
        }, {
            name: 'lastName',
            type: 'string'
        }]
    }
});

Store:

Ext.define('Sencha.store.Contacts', {
    extend: 'Ext.data.Store',
    config: {
        model: 'Sencha.model.Contact',
        sorters: 'firstName',
        autoLoad: true,

        grouper: {
            groupFn: function(record) {
                return record.get('firstName')[0];
            }
        },
        proxy: {
            type: 'ajax',
            url: 'contacts.json'
        }
    }
});

Formatted: app.js

Ext.application({
    phoneStartupScreen: "resources/loading/Homescreen.jpg",
    tabletStartupScreen: "resources/loading/Homescreen~ipad.jpg",
    glossOnIcon: false,
    icon: {
        57: "resources/icons/icon.png",
        72: "resources/icons/icon@72.png",
        114: "resources/icons/icon@2x.png",
        144: "resources/icons/icon@114.png"
    },
    requires: ["Ext.data.Store", "Ext.List", "Ext.field.Search", "Ext.Toolbar"],
    launch: function() {
        var a = this.getListConfiguration();
        if (!Ext.os.is.Phone) {
            Ext.Viewport.add({
                xtype: "panel",
                width: 380,
                height: 420,
                centered: true,
                modal: true,
                hideOnMaskTap: false,
                layout: "fit",
                items: [a]
            }).show()
        } else {
            Ext.Viewport.add(a)
        }
    },
    getListConfiguration: function() {
        return {
            xtype: "list",
            ui: "round",
            pinHeaders: false,
            itemTpl: '<div class="contact">{firstName} <strong>{lastName}</strong></div>',
            store: this.getStore(),
            grouped: true,
            emptyText: '<div style="margin-top: 20px; text-align: center">No Matching Items</div>',
            disableSelection: true,
            items: [{
                xtype: "toolbar",
                docked: "top",
                items: [{
                    xtype: "spacer"
                }, {
                    xtype: "searchfield",
                    placeHolder: "Search...",
                    listeners: {
                        scope: this,
                        clearicontap: this.onSearchClearIconTap,
                        keyup: this.onSearchKeyUp
                    }
                }, {
                    xtype: "spacer"
                }]
            }]
        }
    },
    getStore: function() {
        if (!this.store) {
            this.store = Ext.create("Ext.data.Store", {
                fields: ["firstName", "lastName"],
                sorters: "lastName",
                groupField: "lastName",
                data: [{
                    firstName: "Tommy",
                    lastName: "Maintz"
                }, {
                    firstName: "Rob",
                    lastName: "Dougan"
                }, {
                    firstName: "Ed",
                    lastName: "Avins"
                }, {
                    firstName: "Jamie",
                    lastName: "Avins"
                }, {
                    firstName: "Dave",
                    lastName: "Dougan"
                }, {
                    firstName: "Abraham",
                    lastName: "Elias"
                }, {
                    firstName: "Jacky",
                    lastName: "Ngyuyen"
                }, {
                    firstName: "Jay",
                    lastName: "Ngyuyen"
                }, {
                    firstName: "Jay",
                    lastName: "Robinson"
                }, {
                    firstName: "Rob",
                    lastName: "Avins"
                }, {
                    firstName: "Ed",
                    lastName: "Dougan"
                }, {
                    firstName: "Jamie",
                    lastName: "Poulden"
                }, {
                    firstName: "Dave",
                    lastName: "Spencer"
                }, {
                    firstName: "Abraham",
                    lastName: "Avins"
                }, {
                    firstName: "Jacky",
                    lastName: "Avins"
                }, {
                    firstName: "Rob",
                    lastName: "Kaneda"
                }, {
                    firstName: "Ed",
                    lastName: "Elias"
                }, {
                    firstName: "Tommy",
                    lastName: "Dougan"
                }, {
                    firstName: "Rob",
                    lastName: "Robinson"
                }]
            })
        }
        return this.store
    },
    onSearchKeyUp: function(f) {
        var e = f.getValue(),
            b = this.getStore();
        b.clearFilter();
        if (e) {
            var d = e.split(" "),
                a = [],
                c;
            for (c = 0; c < d.length; c++) {
                if (!d[c]) {
                    continue
                }
                a.push(new RegExp(d[c], "i"))
            }
            b.filter(function(h) {
                var g = [];
                for (c = 0; c < a.length; c++) {
                    var j = a[c],
                        i = h.get("firstName").match(j) || h.get("lastName").match(j);
                    g.push(i)
                }
                if (a.length > 1 && g.indexOf(false) != -1) {
                    return false
                } else {
                    return g[0]
                }
            })
        }
    },
    onSearchClearIconTap: function() {
        this.getStore().clearFilter()
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:14:29+00:00Added an answer on June 1, 2026 at 8:14 pm

    The easiest way to do this is to set an id for your store and get it later using

    Ext.getStore('your-store-id');

    PS: If you get undefined for this, you should create your store first, something like this:

    store = Ext.create('Sencha.store.Contacts');

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Mac App already created and distributed on the App Store to
I have a users model and a book model. Users can read books (as
I have created model, controller and view with rails scaffold generator: rails g scaffold
I have created a model test case in a plugin. Plugin name: Filters and
I'm developing a booking system in Rails 3.1. I have created a model for
if i have created a view model and have a partial form that is
I have created one Catalyst application and I have created Schema and Model using
I have created an entity data model and generated a database from it. One
I have a Model created with a table called Customers. It contains the following
I have created a simple state machine model in Enterprise Architect and exported it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.