Search code examples
extjsgridextjs4clickextjs4.1

Simulate a click event on a grid row


How can I dynamically click rows in my grid?

E.g.: I am using border layout. I have a grid in the west with a list of Companies. When I click on a Company, the information of the company which has an Id, is displayed in a form in my center area.

Now, when I want to add a company ( I am doing this with a button which opens a "Add window"), and type all information in the form and then press "save", I reload the grid. How could I make it, that the company which is newly added, is clicked on and its information is displayed in the center area.

NOTE: The companies are listed with an ajax request, and the information is called with a "onCompanyGridHandler".


Solution

  • You can make the new campany created added in the top of the grid by sorting the grid's store with, for example, the date of campany creation. You can so add this line in the grid's store:

    sorters: { property: 'datecreate', direction : 'DESC' },
    

    Then, after the campany creation, you select the first row of the grid, using this code:

    Ext.getCmp('your_grid_id').getView().select(0);