Description of the Extjs component inheritance template (using GridPanel as an example)

Source: Internet
Author: User

Description of the Extjs component inheritance template (using GridPanel as an example)

1. Override the initComponent () method and call the initComponent () method of the parent class in this method. For example, subclass. superclass. initComponent. call (this );

2. In initComponent, the following statement is displayed, covering the attributes of the parent class Ext. apply (this, {title: "aaa "});

3. the basic template code is as follows: Ext. ns ("my. component "); my. component. myGridPanel = Ext. extend (Ext. gridPanel, {/*** initialize component */initComponent: function () {// var store = this. store; if (! Store) {store = this. buildStore (this. baseParams);} // The column Model var cm = this. cm; if (! Cm) {cm = this. buildCm ();} // check box. use selModel to configure var sm = new Ext. grid. checkboxSelectionMedol (); Ext. apply (this, {// Add the selModel: sm property of the component here, // pagination toolbar bbar: new Ext. pagingToolbar ({}), colModel: new Ext. grid. columnModel ({// Add columns: cm;}), // set the listeners: {"dbclick": function (){}, "rowClick": function (){},......}}); my. component. myGridPanel. superclass. initComponent. apply (this );},/*** Build store */buildStore: function (baseParams) {Ext. apply (baseParams, {// paging condition}); return new Ext. data. jsonStore ({url: "", idProperty: "", // totalProperty: "", // autoLoad: boolean, root: "data" // data root, json format object array. Fields: [{name: "", mapping: ""}, {name: "", mapping: ""},...]});}, /*** construct data column */buildCm: function () {return [{name: "", dataIndex: "" },{ name: "", dataIndex: ""}] ;}, // You can select a model to obtain the selected record. Multiple getSelections: function () {var records = this. getSelectionModel (). getSelections (); return records;} // You can select a model to obtain the selected records. Only one getSelected: function () {var record = this. getSelectionModel (). getSelected ();}});


 
 


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.