首页 新闻 赞助 找找看

Ext gridpanel导出Excel

0
悬赏园豆:40 [已关闭问题] 关闭于 2011-01-21 12:53

 

1 var expander = new Ext.ux.grid.RowExpander({
2 enableCaching: false,
3 lazyRender: false,
4 tpl: new Ext.XTemplate(
5 '<table width=500px>',
6 '<tr height=30px>',
7 '<td>',
8 '奖励名称码:',
9 '</td>',
10 '<td Style="color:Blue">',
11 '{JLMCM}',
12 '</td>',
13 '<td>',
14 '荣誉称号码:',
15 '</td>',
16 '<td Style="color:Blue">',
17 '{RYCHM}',
18 '</td>',
19 '<td>',
20 '获奖角色码:',
21 '</td>',
22 '<td Style="color:Blue">',
23 '{HJJSM}',
24 '</td>',
25 '</tr>',
26 '<tr height=30px>',
27 '<td>',
28 '颁奖单位:',
29 '</td>',
30 '<td colspan=4 Style="color:Blue">',
31 '{BJDW}',
32 '</td>',
33 '</tr>',
34 '<tr height=30px>',
35 '<td colspan=6>',
36 '详细说明:',
37 '</td>',
38 '</tr>',
39 '<tr height=60px>',
40 '<td>',
41 '</td>',
42 '<td colspan=4 Style="color:Blue">',
43 '{Description}',
44 '</td>',
45 '</tr>',
46 '<tr height=30px>',
47 '<td>',
48 '添加日期',
49 '</td>',
50 '<td Style="color:Blue" colspan=4 >',
51 '{CreateTime:date("Y年m月d日 H:i:s")}',
52 '</td>',
53 '</tr>',
54 '</table>'
55 )
56 });
57 var rightsm = new Ext.grid.CheckboxSelectionModel();
58 var rightcm = new Ext.grid.ColumnModel([
59 expander,
60 new Ext.grid.RowNumberer(),
61 rightsm,
62 {
63 header: "获奖项目",
64 dataIndex: 'HJXM',
65 sortable: true
66 }, {
67 header: "奖励方式",
68 dataIndex: 'JLFS',
69 sortable: true
70 }, {
71 header: "奖励名称",
72 dataIndex: 'JLMC',
73 sortable: true
74 }, {
75 header: "荣誉获取日期",
76 dataIndex: 'HRYRQ',
77 renderer: Ext.util.Format.dateRenderer('Y年m月d日'),
78 sortable: true
79 }, {
80 header: "颁奖日期",
81 dataIndex: 'BJRQ',
82 sortable: true,
83 renderer: Ext.util.Format.dateRenderer('Y年m月d日')
84 },
85 {
86 header: "奖励名称码",
87 dataIndex: 'JLMCM',
88 hidden:true,
89 sortable:true
90 }, {
91 header: "荣誉称号码",
92 dataIndex: 'RYCHM',
93 hidden:true,
94 sortable: true
95 }, {
96 header: "获奖角色码",
97 dataIndex: 'HJJSM',
98 hidden:true,
99 sortable: true
100 }, {
101 header: "颁奖单位",
102 dataIndex: 'BJDW',
103 hidden:true,
104 sortable: true
105 }, {
106 header: "详细说明",
107 dataIndex: 'Description',
108 hidden:true,
109 sortable: true
110 }, {
111 header: "添加日期",
112 dataIndex: 'CreateTime',
113 hidden:true,
114 sortable: true,
115 renderer: Ext.util.Format.dateRenderer('Y年m月d日 H:i:s')
116 }
117 ]);
118
119
120
121 var AwardFormReader = new Ext.data.JsonReader({
122 root: 'data',
123 totalProperty: 'total',
124 id: 'Id'
125 }, [
126 {
127 name: 'Personnel.XM',
128 mapping: 'Personnel.XM'
129 },
130 {
131 name: 'AId',
132 mapping: 'Id'
133 },
134 {
135 name: 'HJXM',
136 mapping: 'HJXM'
137 }, {
138 name: 'JLFS',
139 mapping: 'JLFS'
140 }, {
141 name: 'JLMC',
142 mapping: 'JLMC'
143 }, {
144 name: 'JLMCM',
145 mapping: 'JLMCM'
146 }, {
147 name: 'BJDW',
148 mapping: 'BJDW'
149 }, {
150 name: 'HRYRQ',
151 mapping: 'HRYRQ'
152 }, {
153 name: 'RYCHM',
154 mapping: 'RYCHM'
155 }, {
156 name: 'BJRQ',
157 mapping: 'BJRQ'
158 }, {
159 name: 'HJJSM',
160 mapping: 'HJJSM'
161 }, {
162 name: 'Description',
163 mapping: 'Description'
164 }, {
165 name: 'CreateTime',
166 mapping: 'CreateTime'
167 }]);
168
169
170 var rightitemGridStore = new Ext.data.Store({
171 url: "/Award/GetRecordList",
172 reader: AwardFormReader,
173 listeners: {
174 'remove': function (thiz, record, index) {
175 Ext.Ajax.request({
176 url: '/Award/Delete',
177 params: {
178 'Id': record.data.AId
179 },
180 success: function (response, opts) {
181 var result = Ext.util.JSON
182 .decode(response.responseText);
183 if (result.success == false) {
184 JsHelper.ShowError("删除失败!");
185 rightitemGridStore.insert(0, record);
186 } else {
187 Ext.msg.alert("提示", "删除成功!");
188 }
189 rightitemGridStore.load({// 刷新表格
190   params: {
191 start: 0,
192 limit: ALL_PAGESIZE_SETTING,
193 "id": leftSelectId
194 }
195 });
196 leftitemGridStore.load({
197 params: {
198 start: 0,
199 limit: ALL_PAGESIZE_SETTING
200 }
201 });
202 }
203 });
204 }
205 }
206 });
207 rightitemGridStore.setDefaultSort('CreateTime', 'DESC');
208 rightitemGridStore.on('beforeload', function () { //Ext.data.JsonStore读入数据之前的事件,store不需要在写baseParams,因为会覆盖掉. (每次调用都载入此函数,'load'则第一次不调用外,其余都调用).
209 this.baseParams = {
210 "id": leftSelectId
211 };
212 });

 

问题补充: 隐藏列怎么才能导出成Excel呢 或者把RowExpander导出也行
biubiubiu的主页 biubiubiu | 初学一级 | 园豆:114
提问于:2010-11-13 11:07
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册