Every writing article is a history of blood and tears. Recently the company's needs to use the dynamic generation grid ext, the company is 4.0, because the version of the problem in the online find a lot of is not practical, so I researched the next.
Now let's share it with you.
Background json:
Callback content:
1Callback:function(options, success, response) {2 alert (response.responsetext);3 varR =Ext.decode (response.responsetext);4 if("3" = =r.state) {5 varColumnmodel = [];6 varcolumns = [];7 for(vari=0;i<r.responseresult.columnlist.length;i++{//Because the type returned in the background is a string, to convert the string to an object 8 varv =R.responseresult.columnlist[i];9 varobj =NewObject ();Tenobj = {text:v,dataindex:v,width:120}; Onecolumnmodel[i]=obj; AColumns[i] =v; - } - the varDatas = []; - for(vari=0;i<r.responseresult.datalist.length;i++) {//Convert to Object - varv =R.responseresult.datalist[i]; - varSP = V.split (","); + varObjdata =NewObject (); - for(varj=0;j<sp.length;j++){ + varColumnName = sp[j].substring (0,sp[j].indexof (":")); A varColumndata = sp[j].substring (Sp[j].indexof (":") +1, sp[j].length); atObjdata[columnname] =Columndata; - } -datas[i]=Objdata; - } - varstore = ext.create (' Ext.data.Store ', { - Fields:columns, in Data:datas - }); to //Note that columns and Columnmodel must be an array form of object, if the string is in the form of an error! +EXT.GETCMP ("Sydatasourcegird"). Reconfigure (Store,columnmodel); - return ; the } *Ext.create (' Global. Respwin ', {stateoktext:r.msg}). Stateerror (); $}