ExtJS form form automatically loads data (loading data via Ext.data.Model's proxy)

Source: Internet
Author: User

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

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.