In Extjs, after creating a new row of data in the grid page of the current page, I entered the editing of the detailed page through a form. At this time, in order to allow the page to automatically open the detailed page for editing, I spent three hours and finally found the solution in Extjs Find the most suitable solution, but the result is only three sentences. I think this may be what many Extjs enthusiasts want to know or already know. For this reason, I will share it with you, just to contribute some of my own to the extjs community. idea.
After the list is created, there will usually be a prompt. Now I will tell you my first few ideas. If you want to see the results directly, you can skip to the last set of plans~
Option 1 (abandoned). After creating new data, send an id value to the createform method. This may be the first method that ordinary web developers think of, by passing parameters to a detail page, and then the detail searches for the corresponding data in the library based on the ID and displays it on the page. However, after investigation, it was found that the page is displayed through the sub-window of the current page, and the data of the sub-window is passed in through each row of data in the grid. If you want to display the second-level page, you must first display it in the grid. To read out a piece of data, pass the entire value as a record. After adding data, the list itself needs to be updated. It is better to read the latest data in the list directly and pass it in directly. Well, this brings me to the second plan ~
Plan 2 (successful) . After the data is created and the list is updated, set the first item in the list (because it is sorted according to the creation time) to the selected state, and call the onEdit method, which is equivalent to clicking on the first row of data in the grid and clicking the edit button. Effect (ps: Am I very talented?). Okay, after the save data method, call grid.selModel.selectRow(0), and then grid.onEdit() (your own defined editing method, take out the selected row through grid.getSelectionModel().getSelected(), and Pass the parameters to the form), please note that if you select it directly here, it will be the first item before the selected list is updated (not the first item after the update we want)~~ Because the load of the store is loaded asynchronously , haha, so here, we need to put these two methods into the setTimeout function, like this: