这么一来在取得 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.});

最新文章

  1. WinForm/Silverlight多线程编程中如何更新UI控件的值
  2. Objective-c——UI基础开发第九天(QQ好友列表)
  3. Html5 常见的新增API详解
  4. PHP去除数组中重复数据的两个例子
  5. web自己主动保存表单
  6. 不能用100%ie6不兼容
  7. 【树莓PI】下载机
  8. 解决linux ping: unknown host www.baidu.com(转)
  9. 实现LNMP
  10. NEO从入门到开窗(2) - 智能合约的面相
  11. poj 2681 字符串
  12. CSS3文字与字体 text-overflow 与 word-wrap
  13. cmd中mysql主键id自增,在添加信息时发生错误,再次成功添加时,id已经跳过错误的信息继续自增。
  14. BZOJ3224普通平衡树——非旋转treap
  15. [转帖]浅析Servlet执行原理
  16. c# 正则表达式如何处理换行符?
  17. vue教程1-02 data里面存储数据
  18. 微服务RPC框架选美
  19. MVVM Light Toolkit使用指南
  20. Eclipse和MyEclipse的区别 分类: 编程工具 2015-07-18 11:12 23人阅读 评论(0) 收藏

热门文章

  1. CSS_01_CSS和html结合的方式3、4
  2. linux env
  3. Android中实现两次点击返回键退出本程序
  4. 查看linux的出错信息
  5. DataTables使用学习记录
  6. Linux之awk命令详解
  7. 启动管理软件服务器时,提示midas.dll错误
  8. SQL Server 数据库中关于死锁的分析
  9. remote desktop connect btw Mac, Windows, Linux(Ubuntu) Mac,Windows,Linux之间的远程桌面连接
  10. Java 门面模式 浅析