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 8255167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:25:53+00:00 2026-06-08T01:25:53+00:00

I am having a formpanel with no store currently. What I want to acheive

  • 0

I am having a formpanel with no store currently. What I want to acheive is on clicking a button in that panel store the data object of that form in a variable. How to achieve this?

Here is my code:

Ext.define('Nits.view.PropertyPanelCmp', {
            extend:'Ext.form.Panel', 
            alias : 'widget.propertypanelCmp',
            id: 'propertypanelCmp',
            title: 'File properties',
            height: 500,
            width: 200,
            draggable: false,
            closable: false,    
            //autoScroll:true,
            layout: {
                align: 'stretch',
                type: 'vbox'
            },
            fieldDefaults: {
                labelWidth: 65
            },
            bodyPadding: 10,    

            initComponent: function() {
                var me = this;

                me.items = [
                {
                    xtype: 'fieldset',
                    height: 108,
                    title: 'Common Properties',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Name',
                            anchor: '100%'
                        },
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Type',
                            anchor: '100%'
                        },
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Age',
                            anchor: '100%'
                        }
                    ]
                },
                {
                    xtype: 'fieldset',
                    title: 'Level1 Properties',
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Sample1',
                            anchor: '100%'
                        },
                        {
                            xtype: 'checkboxfield',
                            fieldLabel: 'Recursive',
                       //     boxLabel: 'Box Label',
                            anchor: '100%'
                        },
                        {
                            xtype: 'checkboxfield',
                            fieldLabel: 'Delete',
                     //       boxLabel: 'Box Label',
                            anchor: '100%'
                        },
                        {
                            xtype: 'checkboxfield',
                            fieldLabel: 'Read Only',
                         //   boxLabel: 'Box Label',
                            anchor: '100%'
                        },
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Include',
                            anchor: '100%'
                        },
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Exclude',
                            anchor: '100%'
                        }
                    ]
                },
                {
                    xtype: 'fieldset',
                    title: 'Level2 Properties',
                    items: [
                        {
                            xtype: 'combobox',
                            fieldLabel: 'File B',
                            anchor: '100%'
                        }
                    ]
                },
                {
                    xtype: 'button',
                    text: 'Apply',
                    listeners: {
                        click: {
                            fn: me.onButtonClick,
                            scope: me
                        }
                    }
                }
            ];
                me.callParent(arguments);
            },
            //Here do what you want to when click on Apply button
            onButtonClick: function(button, e, options) {
                alert('Sample');
            }
}
);

Need json object for this form elements

  • 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-08T01:25:55+00:00Added an answer on June 8, 2026 at 1:25 am

    You should use Ext.form.Basic.getFieldValues to get the object you need (as covered here in the docs) and then convert it into JSON.

    Following MVC pattern I would put the button handler in a controller, rather than in a view so it would look something like this:

    Ext.define('Nits.controller.MyController', {
        extend: 'Ext.app.Controller',
    
        views:  [
            'PropertyPanelCmp',
        ],
    
        init: function() {
            var me = this;
    
            me.control({
    
                'propertypanelCmp button[text=Apply]': {
    
                    click: function(button) {
                        var form = button.up('propertypanelCmp').getForm(),
                            values = form.getFieldValues(),
                            json = Ext.JSON.encode(values);
    
                        console.log(json);
                        alert(json);
                    }
                }
            });
        }
    }
    

    I suppose if you really wanted the button handler in your view it could look something like this:

    //Here do what you want to when click on Apply button
    onButtonClick: function(button, e, options) {
        var form = this.getForm(),
            values = form.getFieldValues(),
            json = Ext.JSON.encode(values);
    
        console.log(json);
        alert(json);
    }
    

    EDIT

    As you noticed, the fields in the form must have a valid inputId config. That will represent the “key” part of the key/value pairs returned by the getFieldValues call.

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

Sidebar

Related Questions

I'm having real difficulty getting access to a variable that is an attribute of
I am using ExtJS (v3) and I have a form built that I want
Having just added a new button in my web application, I get an error
I have the simple form: myForm = new Ext.form.FormPanel({ width:'100%', frame:false, items: [ new
Having (presumably) understood the motivation behind Nuget, I want to know, whether we still
Having the following domain class: class Message{ } Want to get all messages with
Having a weird issue. I'm new to Macs and have a windows VM that
I'm having an issue with a Struts 1 form, which contains a logic:iterate in
Having difficulty with getting Flowplayer to work nicely with RTMP. This is currently my
Having a list of 3-tuples : [(a, b, c), (d, e, f)] I want

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.