Results 1 to 3 of 3

Thread: Creating a Dynamic Menu items while using s Store.

  1. #1
    Sencha User
    Join Date
    Aug 2017
    Posts
    47
    Answers
    1

    Default Answered: Creating a Dynamic Menu items while using s Store.

    Hello Sencha Community, I have another question for you and hoping you can help me with blocker I am currently facing.

    I am trying to use a Store that will populate a Menu button with several Menu Items. At this time, I have read several sources, but I am still having a difficult time working on it.

    Code:
    Ext.define('extAjaxOnTest.view.financialViewModel', {
        extend: 'Ext.app.ViewModel',
        alias: 'viewmodel.model1',
    
        stores: {
            metaTarget: {
                autoLoad: true,
                model: 'extAjaxOnTest.model.metaTarget',
                proxy: {
                    type: 'ajax',
                    extraParams: {
                        Token: 'token'
                    },
                    url: 'workingURL',
                    reader: {
                        type: 'json'
                    }
                },
                listeners: {
                    load: 'onStoreLoad'
                }
            }
        }
    });
    And here is the button that I am trying to populate at this time with menu items.
    Code:
                        xtype: 'button',
                        reference: 'targetButton',
                        text: 'Target',
                        menu: {
                            xtype: 'menu',
                            id: 'target-menu',
                            width: 120
    As you can see, I have added a listener names onStoreLoad. I know that I need to add my functionality with in the Event Binding.
    To make this easier for Sencha Community, I want to add the information I receive from my Store
    Code:
     {
            "D347": "001",
            "Target": "User1",
            "Push": "2.34",
        },
    I want to populate my Menu Items with "D347": "001", So the menu Item should have an option of 001.

    Thanks for the help in advance
    Regards,
    Jorge

  2. You don't need code from somebody, you need the principle.

    Add items as JS objects.

    So a MenuItem config objects looks like this:

    Code:
    {
        text: 'Item text',
        handler: 'nameOfVCMethod'
    }

  3. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890
    Answers
    41

    Default

    You don't need code from somebody, you need the principle.

    Add items as JS objects.

    So a MenuItem config objects looks like this:

    Code:
    {
        text: 'Item text',
        handler: 'nameOfVCMethod'
    }

  4. #3
    Sencha Premium User
    Join Date
    Oct 2017
    Posts
    3

    Default

    Hi,

    I am also facing the same issue, so kindly let me know if you got the solution.

    Thanks.

    Quote Originally Posted by robzdoom View Post
    Hello Sencha Community, I have another question for you and hoping you can help me with blocker I am currently facing.

    I am trying to use a Store that will populate a Menu button with several Menu Items. At this time, I have read several sources, but I am still having a difficult time working on it.

    Code:
    Ext.define('extAjaxOnTest.view.financialViewModel', {
        extend: 'Ext.app.ViewModel',
        alias: 'viewmodel.model1',
    
        stores: {
            metaTarget: {
                autoLoad: true,
                model: 'extAjaxOnTest.model.metaTarget',
                proxy: {
                    type: 'ajax',
                    extraParams: {
                        Token: 'token'
                    },
                    url: 'workingURL',
                    reader: {
                        type: 'json'
                    }
                },
                listeners: {
                    load: 'onStoreLoad'
                }
            }
        }
    });
    And here is the button that I am trying to populate at this time with menu items.
    Code:
                        xtype: 'button',
                        reference: 'targetButton',
                        text: 'Target',
                        menu: {
                            xtype: 'menu',
                            id: 'target-menu',
                            width: 120
    As you can see, I have added a listener names onStoreLoad. I know that I need to add my functionality with in the Event Binding.
    To make this easier for Sencha Community, I want to add the information I receive from my Store
    Code:
     {
            "D347": "001",
            "Target": "User1",
            "Push": "2.34",
        },
    I want to populate my Menu Items with "D347": "001", So the menu Item should have an option of 001.

    Thanks for the help in advance
    Regards,
    Jorge

Similar Threads

  1. Creating Menu items dynamically
    By Pravin.Pawar in forum Ext: Q&A
    Replies: 2
    Last Post: 4 Sep 2012, 7:58 PM
  2. TabPanel with dynamic Menu items
    By jurajivan in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 8 Apr 2011, 9:31 AM
  3. Problem with dynamic menu items
    By franzisk in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 9 Jun 2007, 7:21 AM

Posting Permissions

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