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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:38:15+00:00 2026-05-24T11:38:15+00:00

My question is so simple it’s in the title! Here’s my code: userCreate: function(button)

  • 0

My question is so simple it’s in the title!

Here’s my code:

userCreate: function(button) {
    var grid = button.up('panel'),
        store = grid.getStore();

    /* Create new empty record */
    var inst = store.add({})[0];
    store.sync();
    /* select the newly created record */
    grid.getSelectionModel().select(inst.id);

    Ext.create('GS.view.user.Edit', { create:true }); 
},  

Now I just want the line after the

    /* select the newly created record */

to work!

I’ve tried many things but none of them work:

    grid.getSelectionModel().select(inst.id);
    grid.getSelectionModel().select(inst);
    grid.getSelectionModel().select(store.last);

Any idea?

Thank you very much

  • 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-24T11:38:17+00:00Added an answer on May 24, 2026 at 11:38 am

    Here’s what I found: ExtJS seems to be lost when there’s no “id” field.
    So after a call to sync() if you didn’t precise an “id” field, it kindof re-organize the grid and can’t find the “old” record (the one I remembered just before the call).
    This is just what I guess, I may be wrong.

    Anyway, I’ve made a turnaround: to stay “homogeneonous”, I’m going to make xxxCreate(), and xxxCreateValidate(), same for xxxUpdate() and xxxUpdateValidate(). I’ve done them for the example: user => userCreate(), userCreateValidate(), userUpdate() and userUpdateValidate():

    init: function () {
        this.control({
            /* (!) Actions in 'userlist' */
            'userlist': {
                itemdblclick: this.userEdit
            },  
            'userlist button[action=create]': {
                click: this.userCreate
            },  
            'userlist button[action=delete]': {
                click: this.userDelete
            },  
            /* (!) Actions in 'useredit' */
            'useredit button[action=create]': {
                click: this.userCreateValidate
            },  
            'useredit button[action=save]': {
                click: this.userEditValidate
            }   
        }); 
    },  
    
    userCreate: function(button) {
        /* Using Ext.create() to pass variable create:true
         * instead of the shortcut:
         * var view = Ext.widget('useredit');
         */
        var view = Ext.create('GS.view.user.Edit', {
            create:true
        }); 
    },  
    
    userCreateValidate: function(button) {
        var win    = button.up('window'),
            form   = win.down('form'),
            values = form.getValues();
    
        this.getUsersStore().add(values);
        this.getUsersStore().sync();
        win.close();
    },  
    
    userEdit: function(grid, record) {
        var view = Ext.widget('useredit');
        view.down('form').loadRecord(record);
    },  
    
    userEditValidate: function (button) {
        var win    = button.up('window'),
            form   = win.down('form'),
            record = form.getRecord(),
            values = form.getValues();
    
        record.set(values);
        win.close();
        this.getUsersStore().sync();
    },
    

    I hope my code will help someone… now I’m looking for a way to handle keys in the Grid. And like everything with ExtJS: you don’t spend your time coding, because everything is already done, you spend your time searching… it’s more frustrating actually =)

    Anyway, the most important thing to note is that the newly added record is not selected. It’s just a workaround to continue to develop, but it’s not what I wanted (it’s not exactly what I’m asking for in the question).

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

Sidebar

Related Questions

Question simple and quick: I have started to use Netbeans to write some code
A simple question, but could someone provide sample code as to how would someone
Question is simple for an expert Integer[][] res= new Integer[][] {.....hard code some values
Question is simple and asked in the title. C# 4.0 Specification says: (§4.2.2) The
Question very simple - say, i got function, which receives array as its arguments
Simple question here. Context: A Transact-SQL table with an int primary key, and a
so simple question! How can I pass a variable into a jQuery function, like
simple question mostly explained in the title. I need to load up a page,
Simple question from an absolute n00b. I'm trying to create an edit content screen
I'm still struggling with my simple javascript game. Here is my previous question: Simple

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.