Results 1 to 4 of 4

Thread: How to call a store from controller

  1. #1

    Default How to call a store from controller

    I have a function in my controller, i want to create an instance of store within that function ,and in store i have an Ajax call function to call Servlet .How can i create the instance and call the Ajax from controller .
    This is my controller


    Ext.define('Gamma.controller.ControlFile', { extend : 'Ext.app.Controller', //define the storesstores : ['BarColumn','RadarView','VoiceCallStore','SMSCallStore','MMSCallStore','GPRSUsageStore'],//define the models models : ['BarCol','radar','VoiceCallModel','SMSCallModel','MMSCallModel','GPRSUsageModel'],//define the viewsviews : ['BarColumnChart','LineChart','RadarChart','VoicePie','SMSPie','MMSPie','GPRSPie'],initializedEvents: false,init: function() { this.control({ '#barColumnChart': { afterlayout: this.afterChartLayout } });},afterChartLayout: function(){ var me=this; if(this.initializedEvents==true) return; this.initializedEvents=true; Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){ var barData=obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count']; me.dataBaseCall(barData); });},dataBaseCall: function(barData){ var bar=getStore('BarColumn'); //here I want to call the ajax}});
    and this is my store ........


    Ext.define('Gamma.store.BarColumn', {extend: 'Ext.data.Store',model: 'Gamma.model.BarCol',autoLoad: true,pageSize: 100, proxy: { type: 'ajax', url: '../TopCount', //this my servlet name reader: { type: 'json', root: 'topList', totalProperty: 'totalCount', successProperty: 'success' }}});

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    When you have a store in the stores array of a controller an instance of that store is created when the controller is initialized. It will have a storeId of whatever the class name is (for example: the store ID would be 'BarColumn' in this case). You can get a reference to the store using Ext.getStore('BarColumn').

    Also, it's helpful if you'll post your code examples in code brackets [ ] and have it formatted with spacing so that it's easier to read. You're more likely to get community participation with easily readable code examples.

  3. #3
    Sencha Premium Member
    Join Date
    May 2013
    Location
    Stevenage, United Kingdom
    Posts
    44
    Answers
    2

    Cool

    First save the store in a variable (called referencing as well)
    var patientsStore = Ext.getStore('Patients');

    And then use patientsStore variable which now refers to Patients Store. E.g. to clear a filter on Patients store:
    patientsStore.clearFilter();

    And to pass a value to store filter (lets say, user enters a value in a field to filter store results):
    patientsStore.filter('PatientID',searchValue);

    Where searchValue is textfield.getValue()

  4. #4
    Sencha User
    Join Date
    Jun 2013
    Posts
    20
    Answers
    1

    Default

    you can get the Store by,

    Code:
    var summaryDataStore = this.getStore('ActivitySummaries');

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •