
1 …………
2
3 @(Html.DevExtreme().DataGrid<Model>()
4 …………
5 .Columns(c =>
6 {
7 …………
8 c.Add()
9 .Type(GridCommandColumnType.Buttons)
10 .Width(110)
11 .Buttons(b =>
12 {
13 b.Add()
14 .Hint("删除")
15 .Text("删除")
16 .OnClick("onDelMetting");
17
18 b.Add()
19 .Hint("取消")
20 .Text("取消")
21 .Visible(new JS("isStatusIconVisible"))
22 .OnClick("onCancelMetting");
23 });
24
25 …………
26
27 })
28 …………
29
30 )
31 <script>
32 //取消事件
33 function onCancelMetting(e) {
34 //console.log(e.row.data);
35 var id= e.row.data.Id; //获取当前行的某一列数据
36 }
37 //删除事件
38 function onDelMetting(e) {
39 //console.log(e.row.data);
40 var id= e.row.data.Id; //获取当前行的某一列数据
41 }
42 //控制按钮显示
43 function isStatusIconVisible(e) {
44 //console.log(e.row.data);
45 return true;
46 }
47 </script>