1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
onTreeNodeClick:
function
(
n)
{
var
grid =
this
.grid
;
//根据传递过来的node,ajax请求服务器获取对应的动态列
Ext.Ajax
.request
(
{
url:
"sample.cfc?method=getDynColumn"
,
params:
{
node:
n.id
}
,
success:
function
(
response,
option)
{
//固定列
var
cm =
[
{
header:
"编号"
,
mapping:
"id"
,
dataIndex:
"id"
,
width:
65
,
menuDisabled:
true
}
,
{
header:
"名称"
,
mapping:
"name"
,
dataIndex:
"name"
,
width:
65
,
menuDisabled:
true
}
,
{
header:
"路径"
,
mapping:
"url"
,
dataIndex:
"url"
,
width:
65
,
menuDisabled:
true
}
]
;
var
fd =
[
"id"
,
"name"
,
"url"
,
"classID"
]
;
var
res =
Ext.util
.JSON
.decode
(
response.responseText
)
;
var
columns =
res.columns
;
var
fields =
res.fields
;
var
types =
res.types
;
//判断具体使用哪种方式进行数据编辑,1为input,2为checkbox,3为radio
for
(
var
i =
0
;
i &
lt;
types.length
;
i++
)
{
var
edit =
null
;
fd.push
(
fields[
i]
.name
)
;
if
(
types[
i]
.type
==
1
)
{
edit =
new
Ext.form
.TextField
(
)
;
}
else
{
if
(
types[
i]
.type
==
2
)
{
edit =
new
Ext.ux
.form
.LovCombo
(
{
store:
new
Ext.data
.JsonStore
(
{
method:
"GET"
,
url:
"sample.cfc?method=getComboboxData"
,
root:
"data"
,
totalProperty:
"totalCount"
,
id:
"id"
,
autoLoad:
true
,
fields:
[
"id"
,
"text"
]
}
)
,
valueField:
"id"
,
displayField:
"text"
,
triggerAction:
"all"
,
editable:
false
}
)
;
}
else
{
edit =
new
Ext.form
.ComboBox
(
{
store:
new
Ext.data
.JsonStore
(
{
method:
"GET"
,
url:
"sample.cfc?method=getComboboxData"
,
root:
"data"
,
totalProperty:
"totalCount"
,
id:
"id"
,
autoLoad:
true
,
fields:
[
"id"
,
"text"
]
}
)
,
valueField:
"id"
,
displayField:
"text"
,
triggerAction:
"all"
,
editable:
false
}
)
;
}
}
columns[
i]
.editor
=
edit;
cm.push
(
columns[
i]
)
;
}
//重新绑定store及column
grid.reconfigure
(
new
Ext.data
.JsonStore
(
{
url:
"sample.cfc"
,
root:
"data"
,
baseParams:
{
method:
"getGridData"
,
node:
n.id
}
,
totalProperty:
"totalCount"
,
id:
"id"
,
fields:
fd
}
)
,
new
Ext.grid
.ColumnModel
(
cm)
)
;
//重新加载数据
var
store =
grid.getStore
(
)
;
grid.getBottomToolbar
(
)
.bind
(
store)
;
store.load
(
{
params:
{
start:
0
,
limit:
5
}
}
)
;
}
}
)
;
}
|