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

  • SEARCH
  • Home
  • 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 8733613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:41:03+00:00 2026-06-13T09:41:03+00:00

does someone knows how to use the same store for chart and for grid

  • 0

does someone knows how to use the same store for chart and for grid
actualy, the question is how to draw a bar chart representing prices for product category in this example

     http://www.mysamplecode.com/2012/06/extjs-local-storage-example.html

code:

 <!DOCTYPE html>
  <html>
    <head>
    <title>ExtJs 4 Local Storage Example</title>

    <link rel="stylesheet" type="text/css"
    href="extjs-4.0.1/resources/css/ext-all.css">

    <script type="text/javascript" src="extjs-4.0.1/ext-all-debug.js"></script>
    <script type="text/javascript" src="app.js"></script>

 </head>
 <body>
 <div id="myExample"></div>
 </body>
 </html>

 Ext.Loader.setConfig({ 
 enabled: true
  });

  Ext.application({

    name: 'myApp',
    appFolder: 'app',

     controllers: [
              'ItemMaster'
          ],

//data container

    launch: function() {
    Ext.create('Ext.container.Container', {
     renderTo: 'myExample',
     height: 250,
        width: 500,
        margin: '5 5 5 5 ',
     layout: 'fit',
        items: [
            {
             xtype: 'itemList'
            }
        ]
    });
  }
});

// model

Ext.define('myApp.model.Product', {
extend: 'Ext.data.Model',
fields: [
      'itemNumber',
      'description',
      'category',
      'price',
      ]
 });

// store

Ext.define('myApp.store.Products', {
extend: 'Ext.data.Store',
model: 'myApp.model.Product',
autoLoad: true,
proxy: {
     type: 'localstorage',
    id  : 'myProxyKey'
}

});

//view

Ext.define('myApp.view.ItemList' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.itemList',
title : 'List of my Store Products',
store : 'Products',
dockedItems: [{
    xtype: 'pagingtoolbar',
    store : 'Products',  
    dock: 'bottom',
    displayInfo: true,
    items: [
            { 
             xtype: 'tbseparator'
            },
            {
                xtype : 'button',
                text: 'Add Product',
                action: 'add'
      }
    ]
}],

initComponent: function() {

 this.columns = [
        {
         header: 'Item Number',  
         dataIndex: 'itemNumber',  
         flex: 1
        },
        {
         header: 'Description', 
         dataIndex: 'description', 
         flex: 2
        },
        {
         header: 'Category',  
         dataIndex: 'category',  
         flex: 1
        },
        {
         header: 'Price', 
         dataIndex: 'price', 
         flex: 1
        }
    ];

    this.callParent(arguments);
   }
   });

// form for adding and editing

 Ext.define('myApp.view.ItemEdit', {
 extend: 'Ext.window.Window',
 alias : 'widget.itemEdit',

 title : 'Product Maintenance',
 layout: 'fit',
 autoShow: true,

 initComponent: function() {
    this.items = [
        {
            xtype: 'form',
            items: [
                {
                    xtype: 'textfield',
                    name : 'itemNumber',
                    fieldLabel: 'Item Number',
                    allowBlank: false,
                    msgTarget: 'side'
                },
                {
                    xtype: 'textfield',
                    name : 'description',
                    fieldLabel: 'Description',
                    allowBlank: false,
                    msgTarget: 'side'
                },
                {
                    xtype: 'combobox',
                    name : 'category',
                    fieldLabel: 'Select Category',
                    store: ["Electronics","Software","Gaming"],
                    queryMode: 'local',
                    value: 'Electronics'
                },
                {
                    xtype: 'numberfield',
                    fieldLabel: 'Price',
                    minValue: 0.01,
                    maxValue: 99.99,
                    value: 9.99,
                    name: 'price'
                }
            ]
        }
    ];

    this.buttons = [
        {
            text: 'Save',
            action: 'save'
        },
        {
            text: 'Cancel',
            scope: this,
            handler: this.close
        }
    ];

    this.callParent(arguments);
    }
   });

//controller

   Ext.define('myApp.controller.ItemMaster', {
   extend : 'Ext.app.Controller',

   stores : ['Products'],
   models : ['Product'],
   views : ['ItemList', 'ItemEdit'],

   init : function() {
   this.control({
   'container > panel' : {
    render : this.onPanelRendered
   },
   'itemList' : {
    itemdblclick : this.editItem
   },
   'itemList button[action=add]' : {
    click : this.addItem
   },
   'itemEdit button[action=save]' : {
    click : this.updateItem
   }
  });
  },

 onPanelRendered : function() {
 //console.log('The panel was rendered');
 },

  editItem : function(grid, record) {
  var view = Ext.widget('itemEdit');
  view.down('form').loadRecord(record);
 },

 updateItem : function(button) {
  var win = button.up('window');
  var form = win.down('form').getForm();
 //check of the form has any errors
 if (form.isValid()) {
 //get the record 
 var record = form.getRecord();
 //get the form values
 var values = form.getValues();
 //if a new record
 if(!record){
  var newRecord = new myApp.model.Product(values);
  this.getProductsStore().add(newRecord);
 }
 //existing record
 else {
  record.set(values);
 }
 win.close();
 //save the data to the Web local Storage
 this.getProductsStore().sync();
}
},

addItem : function(button) {
var view = Ext.widget('itemEdit');
 }
});

thanks

  • 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-13T09:41:04+00:00Added an answer on June 13, 2026 at 9:41 am

    To use the same store, all you need to do is specify the same store for the chart

    {xtype: 'chart', store: 'Products', ...}
    

    Working example http://jsfiddle.net/bucg7/5/

    You also should understand that a store is being magically created in the background by ExtJS, and it’s being assigned the global id of ‘Products’.

    Notice that the chart rerenders as you sort your grid. If you don’t want that behavior, you need two separate stores, where the store for the chart listens to changes from the grid.

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

Sidebar

Related Questions

Does someone knows why the mysql_real_escape_string() function adds three backslashes before quotes, or double
Does someone knows how can I capture my computer screen to a video file?
Does someone knows the image-crop which correctly works with the 'dynamically changed in the
Does someone knows how to calculate the total hours between 2 times? For example
does someone know how to draw 3D surfaces and hide the invisible lines? I
I have a simple small question which someone who knows will be able to
Does someone know a simple way to set the default zoom and latitude/longitude with
Does someone know how to find the longest common subsequence of a set of
Does someone know why i never get the first value of my array? it
Does someone know of a Sqlite manager that I can put on my site,

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.