1. Do not request columns dynamically displayed in the background in the initcomponent method of the grid, because the callparent () method will be prior to the background of your requestCodeExecution, so when you call the parent class method, your columns and store are not created yet, this will be wrong.
The method of the grid should be put into the method of request background parameters when the grid is created, and then the data returned by the request is encapsulated in the initcomponent columns and store, this ensures that columns and store are created before the parent class method is called.
for example, the Class Name of the created grid is Ext. App. wris. Rain. rturesultlistpanel. I want to create the grid when I click the button. The call code is as follows:
listeners :{< br/> CLICK: {<br/> FN: function (OBJ, E, OP) {<br/> If (! Res) {<br/> raincontroller. searchtimecolumnrain (12, function (result, e) {<br/> If (E. status) {<br/> res = result; <br/> var resultpanel = ext. create ('ext. app. wris. rain. rturesultlistpanel '); <br/>}< br/> }); <br/>}
Here, raincontroller. searchtimecolumnrain is the method corresponding to the background, and RES is a defined global variable. If there is a way to not define the global variables, you can call them in the initcomponent method of Ext. App. wris. Rain. rturesultlistpanel.
2. Do not concatenate strings to encapsulate columns and store fields. You should write them as follows:
VaR columns = []; <br/> var Col ={}; <br/> var fields = []; <br/> var field = {}; <br/> for (VAR I = 0; I <res. length; I ++) {<br/> var type = ''; <br/> If (" int "= res [I]. columntype | "float" = res [I]. columntype) {<br/> type = 'number'; <br/>} else {<br/> type = 'string '; <br/>}</P> <p> Col = {<br/> text: res [I]. columndisname, <br/> dataindex: res [I]. columnname <br/>}; <br/> columns. push (COL); </P> <p> If (type = '') {<br/> type = 'auto '; <br/>}</P> <p> Field = {<br/> name: res [I]. columnname, <br/> type: Type <br/>}; </P> <p> fields. push (field); <br/>}
columns is a set of column models, and COL is each column