easyui DataGrid 的 Checkbox 选择多行
2024-08-31 14:02:07
这么一来在取得 DataGrid 的 Checkbox 有勾选的数据值就可以沿用方式一的程序,
1.
$(
'#ButonGetCheck'
).click(
function
(){
2.
var
checkedItems = $(
'#dg'
).datagrid(
'getChecked'
);
3.
var
names = [];
4.
$.each(checkedItems,
function
(index, item){
5.
names.push(item.productname);
6.
});
7.
console.log(names.join(
","
));
8.
});
执行结果:
完整 Javascript 程序如下:
01.
$(
function
(){
02.
$(
'#dg'
).datagrid({
03.
title:
'CheckBox Selection on DataGrid'
,
04.
url:
'datagrid_data3.json'
,
05.
width:
'700'
,
06.
rownumbers:
true
,
07.
columns:[[
08.
{field:
'checked'
,formatter:
function
(value,row,index){
09.
if
(row.checked){
10.
return
'<input type="checkbox" name="DataGridCheckbox" checked="checked">'
;
11.
}
12.
else
{
13.
return
'<input type="checkbox" name="DataGridCheckbox">'
;
14.
}
15.
}},
16.
{ field:
'productid'
, title:
'productid'
},
17.
{ field:
'productname'
, title:
'productname'
},
18.
{ field:
'unitcost'
, title:
'unitcost'
},
19.
{ field:
'status'
, title:
'status'
},
20.
{ field:
'listprice'
, title:
'listprice'
},
21.
{ field:
'itemid'
, title:
'itemid'
}
22.
]],
23.
singleSelect:
true
24.
});
25.
26.
$(
'#ButonGetCheck'
).click(
function
(){
27.
var
checkedItems = $(
'#dg'
).datagrid(
'getChecked'
);
28.
var
names = [];
29.
$.each(checkedItems,
function
(index, item){
30.
names.push(item.productname);
31.
});
32.
console.log(names.join(
","
));
33.
});
34.
});
35.
36.
$.extend($.fn.datagrid.methods, {
37.
getChecked:
function
(jq) {
38.
var
rr = [];
39.
var
rows = jq.datagrid(
'getRows'
);
40.
jq.datagrid(
'getPanel'
).find(
'div.datagrid-cell input:checked'
).each(
function
() {
41.
var
index = $(
this
).parents(
'tr:first'
).attr(
'datagrid-row-index'
);
42.
rr.push(rows[index]);
43.
});
44.
return
rr;
45.
}
46.
});
最新文章
- WinForm/Silverlight多线程编程中如何更新UI控件的值
- Objective-c——UI基础开发第九天(QQ好友列表)
- Html5 常见的新增API详解
- PHP去除数组中重复数据的两个例子
- web自己主动保存表单
- 不能用100%ie6不兼容
- 【树莓PI】下载机
- 解决linux ping: unknown host www.baidu.com(转)
- 实现LNMP
- NEO从入门到开窗(2) - 智能合约的面相
- poj 2681 字符串
- CSS3文字与字体 text-overflow 与 word-wrap
- cmd中mysql主键id自增,在添加信息时发生错误,再次成功添加时,id已经跳过错误的信息继续自增。
- BZOJ3224普通平衡树——非旋转treap
- [转帖]浅析Servlet执行原理
- c# 正则表达式如何处理换行符?
- vue教程1-02 data里面存储数据
- 微服务RPC框架选美
- MVVM Light Toolkit使用指南
- Eclipse和MyEclipse的区别 分类: 编程工具 2015-07-18 11:12 23人阅读 评论(0) 收藏