ExtJS 4.0 Dynamic grid generation

Source: Internet
Author: User

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 (); $}

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.