ASP.NET MVC3 使用Flexigrid 问题
时间:2011-01-04 来源:bill.yang
加载前代码:

2 $("#@Model.RenderElement").flexigrid({
3 url:"@Model.Action",
4 type:"POST",
5 dataType:"json",
6 colModel:[
7 @foreach(var item in Model.FlexGridAttr)
8 {
9 <text>
10 {display:'@(item.Value.DisplayName == null ? item.Key:item.Value.DisplayName)'
11 name:'@item.Key',
12 width:'@(item.Value.Width <=0 ? "50" : item.Value.Width.ToString())',
13 sortable:@item.Value.Sortable.ToString().ToLower(),
14 algin:'@(item.Value.Align == null ? "Left" : item.Value.Align)'
15 }
16 @if (count + 1 != Model.FlexGridAttr.Count)
17 {
18 <text>,</text>
19 }
20 </text>
21 count++;
22 }
23 ],
24 buttons:[
25 {name:"新增",bclass:'add',onpress=test},
26 {name:"删除",bclass:'delete',onpress:test},
27 {separator:true}
28 ],
29 @if(0 < Model.FlexGridAttr.Where(p => p.Value.IsSearch == true).Count())
30 {
31 Write("searchitems : [");
32 foreach(var item in Model.FlexGridAttr)
33 {
34 if(item.Value.IsSearch)
35 {
36 <text>{dispaly:'@(item.Value.DisplayName == null ? item.Key : item.Value.DisplayName)',name:'@item.Key'},</text>
37 }
38 }
39 Write("],");
40 }
41 @if(Model.FlexGridAttr.Count>0)
42 {
43 <text>sortname:"@Model.FlexGridAttr.Keys.First()",</text>
44 }
45 sortorder:"asc",
46 usepager:true,
47 title:"@Model.Title",
48 useRp:true,
49 rp:15,
50 showTableToggleBtn:true,
51 width:700,
52 });
54 });
加载后代码:

$("#grid").flexigrid({
url:"/Advance/GetAppListData",
type:"POST",
dataType:"json",
colModel:[
{display:'菜单名称'
name:'SysAppName',
width:'50',
sortable:false,
algin:'Left'
}
,
{display:'系统名称'
name:'SysAppEName',
width:'50',
sortable:false,
algin:'Left'
}
,
{display:'Controller'
name:'SysAppController',
width:'50',
sortable:false,
algin:'Left'
}
,
{display:'Action'
name:'SysAppAction',
width:'50',
sortable:false,
algin:'Left'
}
],
buttons:[
{name:"新增",bclass:'add',onpress=test},
{name:"删除",bclass:'delete',onpress:test},
{separator:true}
],
sortname:"SysAppName",
sortorder:"asc",
usepager:true,
title:"菜单管理",
useRp:true,
rp:15,
showTableToggleBtn:true,
width:700,
});
相关阅读 更多 +
排行榜 更多 +