


Solution to automatically load the Extjs list details window after it is created_extjs
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:
setTimeout(function(){
Ext.getCmp("gridPanel").sm.selectRow(0);
Ext.getCmp("gridPanel").onEdit() ;
},300);
Just set the delay and then execute the selection and editing methods. Have you noticed that I am using getCmp instead of this.grid? Because the scope of setTimeout in js is global, if a local variable is used here, js will report an error of "undefined object or method". However, I found another problem when I was using it. The delay time felt a bit long, and people always felt uncomfortable when there was a delay. Can it be done without using this function? Ever since, the ultimate plan is about to be released! This is a method I found after trying hard to no avail. Hehe, it feels a little opportunistic. Don’t laugh at me, haha~
I am also a novice. I just learned Extjs not long ago, and I am not that familiar with js. , I guess for experienced people, these small problems are trivial and are not taken seriously, but I still feel a sense of accomplishment after thinking about this. Experts just skip it and don’t listen to my ramblings, haha~
Option 3 ( Best). Select the list in the callback function of the Extjs message window and open the details. This is my best solution. Because I found that Ext provides four parameters for the Ext.Msg.alert() method, namely title, msg, fn, scope (see reference blog post). Among them, fn is the content of the callback function block, which will be called after clicking the button. function, I put the above two lines of code in the callback function, which solved the two major problems of delayed loading and user experience. It is really the best of both worlds, why not?
Ext.Msg.alert("Prompt message", " Created successfully, please enter detailed information!", function() {
this.grid.sm.selectRow(0);
this.grid.onEdit();
}, this);
Although the code seems to be only a few lines, it consumes a lot of my brain cells. In order to come up with this solution, I tried and debugged it dozens of times. If you find it useful, don’t forget to like it~
In the process of solving the problem, I referred to the following blog post:
ExtJS Ext.MessageBox.alert() pop-up dialog box detailed explanation

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



As the PHP language becomes more and more popular, developers need to use more and more classes and functions. When a project grows in size, manually introducing all dependencies becomes impractical. At this time, an automatic loading mechanism is needed to simplify the code development and maintenance process. The auto-loading mechanism is a feature of the PHP language that can automatically load required classes and interfaces at runtime and reduce manual class file introduction. In this way, programmers can focus on developing code and reduce errors and time waste caused by tedious manual class introduction. In PHP, generally

With the continuous development and popularity of Web applications, more and more companies and individuals are beginning to use PHP and ExtJS to build powerful Web applications. As a popular server-side scripting language, PHP is cross-platform and easy to learn, while ExtJS is a popular front-end framework that can help developers quickly build interactive web application interfaces. This article will introduce how to use PHP and ExtJS to implement powerful web application functions. Establish PHP and MySQL database connections for use

How can JavaScript achieve automatic scaling of content when scrolling to the bottom of the page and maintain the aspect ratio effect? In modern web design, scrolling to the bottom of the page to automatically load more content has become a common feature requirement. When the loaded content contains images, we often want these images to maintain their original aspect ratio. This article will introduce how to use JavaScript to implement this function and provide corresponding code examples for reference. First, we need to get the scroll position of the page. inJavaScr

How to use PHP7's namespace and automatic loading mechanism to organize the structure of the code? Abstract: With the launch of PHP7, namespace and automatic loading mechanism have become important features that cannot be ignored in PHP development. This article will introduce how to use PHP7's namespace and automatic loading mechanism to organize the structure of the code, and illustrate it through specific code examples. 1. What is a namespace? Namespace is a mechanism introduced in PHP7 to resolve naming conflicts that may occur between different class libraries or code files. via namespace

Composer is a very popular dependency management tool in PHP. It can help us manage the third-party libraries and components needed in the project and automatically load these libraries and components. This article will introduce how to use Composer for automatic loading in PHP. Install Composer First, you need to install Composer. You can download the latest version of Composer at https://getcomposer.org/download/ and install it. InitializeComp

How does JavaScript achieve the fade-in effect of automatically loading content after scrolling to the bottom of the page? In modern web design, it is a very common requirement to scroll to the bottom of the page to automatically load content with a fade-in effect. This article will use JavaScript as an example to introduce how to achieve this effect. First, we need to use JavaScript to listen for page scroll events. When scrolling to the bottom of the page, we will trigger a function that loads new content. //Listen to the page scroll event window.addEv

Introduction to PHP Autoloading PHP autoloading is a mechanism that allows PHP to automatically load classes when needed without manually including the files. This greatly simplifies the development of large applications and improves code maintainability. Namespaces and Autoloading Namespaces in PHP are used to organize code. When a class declared using a namespace needs to be loaded, PHP will perform an automatic loading process. The autoloader is responsible for finding and loading the corresponding class files based on the namespace and class name. Automatic loading using Composer Composer is the standard tool in the PHP community for dependency management and automatic loading. After installing Composer, you can configure autoloading using the following steps: //composer.JSO

How does JavaScript achieve the gradient display effect of automatically loading content when scrolling to the bottom of the page? In modern web design, scrolling to the bottom of the page to automatically load content is a common requirement. In order to improve the user experience, gradient display effects are also a common design option. So, how do we implement it in JavaScript? Specific implementation steps and code examples are given below. The main idea to achieve this effect is to monitor the scroll event of the page and determine whether the bottom of the page has been reached based on the scroll position.
