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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:50:45+00:00 2026-05-26T08:50:45+00:00

i have a form panel and a tree panel the form is used to

  • 0

i have a form panel and a tree panel
the form is used to add new users, the tree is used to show the list of users

what i want is to right click a node in my tree ,click edit (already can do that) then i have my data in the add form panel and be able to modify there and update my user

so basically use the same form for adding and updating

this is how im trying to do up to know
but its not working at all

i added a model to my tree,i used loadRecord(rec), but i dont know how to bind my tree data with the form fields!
tried adding displayfield with same name from my tree model!!

my tree model and store:

Ext.define('TreeModel', {
extend: 'Ext.data.Model',
fields: [
        { name: 'text' },
        { name: 'id' }
    ]
});

window.ATreeStore = Ext.create('Ext.data.TreeStore', {
model: 'TreeModel',
root: Ext.decode(objt.TreeToJson()),
proxy: {
    type: 'ajax'
},
sorters: [{
    property: 'leaf',
    direction: 'ASC'
}, {
    property: 'text',
    direction: 'ASC'
}]
});

my tree menu:

var myContextMenu = new Ext.menu.Menu({
items: [{
    text: 'Edit',
    handler: function () {

        Ext.getCmp('addaform').getForm().loadRecord(rec);

    }
}
}]

my form:

Ext.define("Ext.app.Adduser", {
extend: "Ext.form.Panel",

title: 'Add user',
id : 'addform',
closable: true,
collapsible: true,
animCollapse: true,
draggable: true,
resizable: true,
margin: '5 5 5 5',
height: 400,
frame: true,
fieldDefaults: {
    labelAlign: 'top',
    msgTarget: 'side'
},
defaults: {
    anchor: '100%'
},
items: [{
    layout: 'column',
    border: false,
    items: [{
        padding: '5',
        columnWidth: .5,
        border: false,
        layout: 'anchor',
        defaultType: 'textfield',
        items: [{
            fieldLabel: ' Name',
            name: 'name',
            allowBlank: false,
            displayfield:'id',//
            anchor: '95%'
        }]
    }, {
        padding: '5',
        columnWidth: .5,
        border: false,
        layout: 'anchor',
        defaultType: 'textfield',
        items: [{
            fieldLabel: 'First name',
            name: 'fname',
            allowBlank: false,
            anchor: '95%'
        }, {
            xtype: 'textarea',
            fieldLabel: 'Profile',
            name: 'prof',
            anchor: '95%'
        }]
    }],

buttons: [{
    text: 'Save',
    handler: function () {
        this.up('form').getForm().submit
                        ({
                            url: 'AddData.ashx',
                            params: { action: 'add' },
                            success: function (form, action) 
                            {
                                Ext.MessageBox.show({ title: 'Success !',
                                                      msg: 'User added successfully<br />',
                                                      icon: Ext.MessageBox.INFO,
                                                      buttons: Ext.MessageBox.OK
                                                  }) }
}) }]

thank you

  • 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-05-26T08:50:46+00:00Added an answer on May 26, 2026 at 8:50 am

    If your TreePanel uses a TreeStore which in turn has a Ext.data.Model, then when you right click on a node (say nodeA), you should be just able to do form.loadRecord(nodeA), the API for loadRecord is here

    If it’s still not clear, I think this blog post could help, it talks about loading a grid record into a form. I know it’s not ExtJS 4, but the key functions are the same.

    Ok, let me show this with a super simple example, hope it will help.

    First we create the form that we want to display stuff in, note that the renderTo property is bound to a div inside my HTML, so you might need to change that. Also note that the name property of the textarea and textfield, they are the key for the loadRecord to work, they have to match the fields defined in the model later.

    var form = Ext.create('Ext.form.Panel',{
        renderTo : 'form-div',
        items : [{
            xtype : 'textarea',
            fieldLabel : 'label 1',
            name : 'name'           
        },{
            xtype : 'textfield',
            fieldLabel : 'label 2',
            name : 'age'
        }]
    });
    

    Next, we create the tree to display our data, we start by creating a simple model :

    Ext.define('Person',{
        extend : 'Ext.data.Model',
        fields : [{
            name : 'name', 
            type : 'string'
        },{
            name : 'age',
            type : 'int'
        }]
    });
    

    Then we create a TreeStore that uses that model and initialize it with some inline data:

    var store = Ext.create('Ext.data.TreeStore',{
        model : 'Person',
        root : {
            expanded : true,
            children : [{
                name : 'John',
                age : 10,
                leaf : true
            },{
                name : 'Joe',
                age : 100,
                leaf : true
            }]
        }
    });
    

    Then we create the tree to display the data in the store. (Note that the nodes will show up as “undefined” because we are not using the default “text” property of a Node)

    var tree = Ext.create('Ext.tree.Panel',{
        height : 300,
        width : 300,
        store : store,
        rootVisible : false,
        renderTo : 'tree-div',
        listeners : {
            itemclick : function(view, record){
                form.loadRecord(record);
            }
        }
    });
    

    Now, you should see a tree with two nodes both displayed as “undefined” on your page, as well as a Form with a textarea and a textfield. If you click on a node inside the tree, the form will display the name and age of the selected node.

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

Sidebar

Related Questions

I have a form with a panel in which I want to display an
I have 4-5 grid panels, one form panel and want to put it into
I have created Form and Grid Panel in Extjs now i want to display
I have a form panel and i want text fields stick to their labels
I have a form that will multiple Panel controls stacked on top of each
I have a form where controls are dynamically added to a Panel. However, when
I have form area in my view. If I click button A , I
I have form with 1 button. when you click on the button 3 others
I have a form with a panel docked in it. I then dynamically create
Learning .NET: I have a form with a split container, I want to load

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.