The form of Extjs automatically loads data (data is loaded through the agent of Ext. data. Model)

Source: Internet
Author: User

A problem occurred during project creation. When double-clicking a row of data on the grid page, double-click the row to automatically load the data to the double-click Page (Ext pop-up box ), you can use this. down (''form ). getForm (). loadRecord (record) to automatically load, but now there is a need to double-click the grid row to pop up a new browser page (not the ext pop-up box, through the window. open () Implementation), you can only upload the double-click id to the page, and then re-query the data to manually assign values. If there are many page fields, it is very hard to assign values one by one, so I thought I could not automatically load the data. After a long period of research, I found that this. down (''form ). getForm (). loadRecord (record) The record is actually an Ext. data. the Model object. If I encapsulate the retrieved data into a model object, this method will not automatically load the object. Through the experiment, we can. the following is code 1: form code of the front-end Ext. Description: defines an Ext of 'selectname. data. the Model object accesses the background data through the ajax proxy. In this case, the code is only defined and the method cannot be executed to obtain the data var selectName = Ext. define ('selectname', {extend: 'ext. data. model ', fields: ['id', 'bugnumber', 'title'], proxy: {type: 'ajax', url: 'pribugmanage/controller/gettestdata'}); 2: SpringMVC in the background (not explained too much here). It indicates that the map object is returned through the background, the key value of the map object must be the name of the field in the form of the object ext/*** problem single database, add, query, approval */@ Controller @ RequestMapping ("/pribugmanage/controller") public class PrjBugManagerController {/*** get data */@ RequestMapping (value = "/getTestData ") @ ResponseBody public Map <String, Object> getTestData (final Integer id) {return prjBugManagerService. getTestData (id) ;}@ Autowired private PrjBugManagerService prjBugManagerService;} Steps 3: 1 and 2 are just defined. To complete the query, perform the third step. After listening to the page, use the Ext. data. the load method of the Model object is used to access the background. After successful execution, the success method of the callback function is called. A record object, that is, Ext, is returned. data. model. We can use me. down ('form '). getForm (). loadRecord (record); to automatically load the listeners: {render: function () {selectName. load (dataId, {success: function (record, operation) {me. down ('form '). getForm (). loadRecord (record );}});}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.