When doing the project encountered a problem, previously double-click on the grid page row of data, will double-click the data of this row automatically loaded into the double-click page (ext pop-up), you can pass This.down ("form)." GetForm (). Loadrecord ( Record) to automatically load, but now there is a need to double-click the grid to pop up a new browser page (not the Ext pop-up box, through the window.open () implementation), can only double-click the ID to the page, and then re-check the data manually assigned value, if a page field many, One assignment is very hard, so I want to be able to automatically load the data
The long-time study found that This.down ("form"). GetForm (). Loadrecord (record) where the record is actually a Ext.data.Model object, If I encapsulate the data that I've found into a model object, it can be loaded automatically by this method, and it can be done by experiment. Here's the code.
1: The form code of the foreground ext, Description: Define a ' selectname ' Ext.data.Model object to access the background data through the AJAX proxy, this code is just a definition, and cannot execute method to get the data
var selectname=ext.define (' Selectname ', {extend: ' Ext.data.Model ', fields: [' id ', ' bugnumber ', ' title '],proxy:{type: ' Ajax ', url: ' Pribugmanage/controller/gettestdata '}});
2: Backstage is SPRINGMVC (here does not do too much explanation), explained: The Map object is returned by the background, the key value of the map corresponds to the name of the field in the form of the Ext form.
/** * Problem list, add, query, approve */@Controller @requestmapping ("/pribugmanage/controller") public class Prjbugmanagercontroller {/* * * Obtain Data */@RequestMapping (value = "/gettestdata") @ResponseBodypublic map<string, object> gettestdata (final Integer ID) {return prjbugmanagerservice.gettestdata (ID);} @Autowiredprivate Prjbugmanagerservice Prjbugmanagerservice;}
The 3:1 and 22 steps are just the definition, the third step to complete the query (Dataid is an ID to get the data that needs to be queried)
This is done by listening, listening, after the page is loaded, through the Ext.data.Model object's Load method just defined by the "selectname" to perform the access to the background, after the successful execution of the call callback function success method, where the face will return a record object, That is Ext.data.Model, which is what we can do by Me.down (' form '). GetForm (). Loadrecord (record) to automatically load data for the current form form
Listeners:{render:function () {selectname.load (Dataid,{success:function (record,operation) {me.down (' form '). GetForm (). Loadrecord (record); }});}}
This article is original, reprint please explain the reprint address