Extjs component inheritance template description (using GridPanel as an example), extjsgridpanel
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 ();}});
How to add a search box (text box + button) to GridPanel in extjs
Configure it directly to the toolbar tbar:
Var grid = new Ext. grid. GridPanel ({
Id: "grid1 ",
Title: "GridPanel instance ",
RenderTo: "div1 ",
Width: 500,
Height: 300,
Frame: true,
Tbar: [{xtype: 'label', text: 'enter keywords:'}, {xtype: 'textfield ', id: 'keyword'}, {text: 'search', handler: function () {alert ("Search ");}}
],
..... // Other configuration items
});
How does extjs display a dynamically generated component (grid) and reload the obtained json data?
The answer I wrote is actually an invalid character. Depressed enough, I can only send images. I hope the administrator can see why the text I wrote cannot be sent.