惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cisco Blogs
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
Hacker News: Ask HN
Hacker News: Ask HN
Schneier on Security
Schneier on Security
H
Heimdal Security Blog
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cyberwarzone
Cyberwarzone
V2EX - 技术
V2EX - 技术
W
WeLiveSecurity
Help Net Security
Help Net Security
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
S
Securelist
SecWiki News
SecWiki News
P
Palo Alto Networks Blog
C
CERT Recently Published Vulnerability Notes
Know Your Adversary
Know Your Adversary
The Last Watchdog
The Last Watchdog
N
News | PayPal Newsroom
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
H
Hacker News: Front Page
NISL@THU
NISL@THU
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Google Online Security Blog
Google Online Security Blog
The Hacker News
The Hacker News
Cloudbric
Cloudbric
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
A
Arctic Wolf
Latest news
Latest news
S
Schneier on Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
Project Zero
Project Zero
P
Privacy International News Feed
B
Blog
云风的 BLOG
云风的 BLOG

博客园 - MHL

C#:类的成员--事件 SSRS 2016 Forms Authentication 存储配置关系&知识图谱 Neo4j 使用cypher语言进行查询 项目实战--知识图谱初探 - MHL - 博客园 .NET Core多语言 ASP.NET Core WebApi 返回统一格式参数 C#启动外部程序以及等待外部程序关闭的几种方法 开源.net 混淆器ConfuserEx介绍 CRUD Operations In ASP.NET MVC 5 Using ADO.NET asp.net mvc 利用过滤器进行网站Meta设置 【译】RAID的概念和RAID对于SQL性能的影响 【转】Sql server锁,独占锁,共享锁,更新锁,乐观锁,悲观锁 One Day WinForm简单进度条 金庸群侠传 3小时爆机 ExtJs Set PropertyGrid Column Name 电脑上玩 Google纵横 Microsoft Visual Studio 2010 宣传短片
ExtJs GridPanel 生成列
MHL · 2010-05-25 · via 博客园 - MHL

最近在用ExtJS做项目,此部分代码为自动生成gridpanel列

 1:  <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
 2:  
 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4:  
 5:  <html xmlns="http://www.w3.org/1999/xhtml" >
 6:  <head id="Head1" runat="server">
 7:      <title>CICompare</title>
 8:      <script type="text/javascript">
 9:  
10:          Ext.Ajax.request({
11:              url: '/CI/BuildCM', //asp.net mvc action
12:              method: 'GET',
13:              success: function (responseObject) {
14:                  var responseArray = Ext.util.JSON.decode(responseObject.responseText);
15:                  //var fieldNames = responseArray.fieldsNames;
16:                  //alert(Ext.util.JSON.encode(responseArray.columModle));
17:                  var CICompare_store = new Ext.data.JsonStore({
18:                      proxy: new Ext.data.HttpProxy({
19:                          url: '/CI/LogicDevice' // get json asp.net mvc action
20:                      }),
21:                      autoDestroy: true,
22:                      storeId: 'myStore',
23:                      root: 'images',
24:                      idProperty: 'name',
25:                      fields: responseArray.fieldsNames
26:                  });
27:   
28:                  var mediaGrid_cm = new Ext.grid.ColumnModel(responseArray.columModle);
29:                  var CICompare_grid = new Ext.grid.GridPanel({
30:                      id: 'CICompare_grid',
31:                      renderTo: 'CICompare_div_grid',
32:                      autoHeight: true,
33:                      autoScroll: true,
34:                      fitContainer: true,
35:                      store: CICompare_store,
36:                      stripeRows: true,
37:                      viewConfig: {
38:                          forceFit: true
39:                      },
40:                      cm: mediaGrid_cm
41:                  });
42:                  CICompare_store.load();
43:              }
44:          })
45:   
46:   
47:      </script>
48:  </head>
49:  <body>
50:  <div id="CICompare_div_grid">   </div>
51:  </body>
52:  </html>
53:  

Controller Code

 1:   //[ExtJsGridJson]
 2:          public ActionResult LogicDevice()
 3:          {
 4:              //DAO.CIDAO dao = new CIDAO();
 5:              //DataSet ds = dao.PagerLogicDevice(start, limit);
 6:              //this.ViewData["PagerData"] = ds;
 7:  
 8:              return this.Content(@"{
 9:      'images':[
10:          {'name':'gangster_zack.jpg','size':2115,'lastmod':1207259034000,'url':'images\/thumbs\/gangster_zack.jpg'},
11:          {'name':'kids_hug.jpg','size':2477,'lastmod':1207259034000,'url':'images\/thumbs\/kids_hug.jpg'},
12:          {'name':'sara_smile.jpg','size':2410,'lastmod':1207259034000,'url':'images\/thumbs\/sara_smile.jpg'},
13:          {'name':'sara_pink.jpg','size':2154,'lastmod':1207259034000,'url':'images\/thumbs\/sara_pink.jpg'},
14:          {'name':'zack_dress.jpg','size':2645,'lastmod':1207259034000,'url':'images\/thumbs\/zack_dress.jpg'},
15:          {'name':'zacks_grill.jpg','size':2825,'lastmod':1207259034000,'url':'images\/thumbs\/zacks_grill.jpg'},
16:          {'name':'kids_hug2.jpg','size':2476,'lastmod':1207259034000,'url':'images\/thumbs\/kids_hug2.jpg'},
17:          {'name':'zack.jpg','size':2901,'lastmod':1207259034000,'url':'images\/thumbs\/zack.jpg'},
18:          {'name':'sara_pumpkin.jpg','size':2588,'lastmod':1207259034000,'url':'images\/thumbs\/sara_pumpkin.jpg'},
19:          {'name':'zack_hat.jpg','size':2323,'lastmod':1207259034000,'url':'images\/thumbs\/zack_hat.jpg'},
20:          {'name':'up_to_something.jpg','size':2120,'lastmod':1207259034000,'url':'images\/thumbs\/up_to_something.jpg'},
21:          {'name':'zack_sink.jpg','size':2303,'lastmod':1207259034000,'url':'images\/thumbs\/zack_sink.jpg'},
22:          {'name':'dance_fever.jpg','size':2067,'lastmod':1207259034000,'url':'images\/thumbs\/dance_fever.jpg'}
23:          ]
24:  }");
25:              //return new EmptyResult();
26:          }
27:   
28:          public ActionResult BuildCM()
29:          {
32:              StringBuilder j = new StringBuilder();
33:   
34:              j.Append("{");
35:              j.Append("'fieldsNames':['name', 'url', {'name':'size', 'type': 'float'}, {'name':'lastmod', 'type':'date'}]");
36:              j.Append(",");
37:              j.Append("'columModle':[{'header':'','dataIndex':'name','align':'center'},{'header':'有D啊?爱?偶?','dataIndex':'url','align':'center'},{'header':'lastmod','dataIndex':'lastmod','align':'center'}]");
38:              j.Append("}");
39:              return this.Content(j.ToString());
40:          }
41: