实现如下功能:

代码:

<table id="dg" class="easyui-datagrid" title="Merge Cells for DataGrid" style="width:700px;height:750px"
data-options="
rownumbers: true,
singleSelect: false,
iconCls: 'icon-save',
url: '../datagrid/datagrid_data1.json?n='+Math.random(),
method:'get',
onLoadSuccess: onLoadSuccess,
checkOnSelect:true,
selectOnCheck:true,
onCheck:onCheck,
onUncheck:onUncheck
">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'productid',width:100">Product</th>
<th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'listprice',width:80,align:'right'">List Price</th>
<th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
<th data-options="field:'attr1',width:240">Attribute</th>
<th data-options="field:'status',width:60,align:'center'">Status</th>
</tr>
</thead>
</table>
<script type="text/javascript">
//判断rowIndex是否被选中
//调用方法:$("#dg").datagrid("isChecked", { rowIndex: rowIndex })
$.extend($.fn.datagrid.methods, {
isChecked: function (dg, param) {
var flag = false;//是否选中
var allRows = $(dg).datagrid('getChecked'); //获取所有被选中的行
$.each(allRows, function (index,item) {
if (param.rowIndex == $(dg).datagrid('getRowIndex', item)) {
flag = true;
return false;//return false终止循环,return true,跳出循环,进入下一次循环,跟函数返回值无关
}
})
return flag;
}
})
var index = '';
function onCheck(rowIndex, rowData) {
if (index == '') {
index = rowIndex;
var productid = rowData["productid"];
var rows = $("#dg").datagrid("getRows");
//alert($("#dg").datagrid("isChecked", { rowIndex: rowIndex }));
for (var i = 0; i < rows.length; i++) {
if (rows[i]["productid"] == productid) {
$("#dg").datagrid("checkRow", i);
}
}
index = '';
}
}
function onUncheck(rowIndex, rowData) {
if (index == '') {
index = rowIndex;
var productid = rowData["productid"];
var rows = $("#dg").datagrid("getRows");
//alert($("#dg").datagrid("isChecked", { rowIndex: rowIndex }));
for (var i = 0; i < rows.length; i++) {
if (rows[i]["productid"] == productid) {
$("#dg").datagrid("uncheckRow", i);
}
}
index = '';
}
}
function onLoadSuccess(data){
var merges = [{
index: 1,
rowspan: 3
}];
for(var i=0; i<merges.length; i++){
$(this).datagrid('mergeCells',{
index: merges[0].index,
field: 'productid',
rowspan: merges[0].rowspan
}).datagrid('mergeCells', {
index: merges[0].index,
field: 'ck',
rowspan: merges[0].rowspan
});
}
}
</script>

easyui_datagrid合并行单击某行选中所有的更多相关文章

  1. 基于jquery 全选、反选、各行换色、单击行选中事件实现代码

    <script language="javascript"> $(document).ready(function(){ //各行换色 $('table tr:odd' ...

  2. 使用自连接、for xml path('')和stuff合并显示多行数据到一行中(转)

    原文: http://njm.iteye.com/blog/795881 --使用 自连接.for xml path('')和stuff合并显示多行数据到一行中 --注 --1.计算列可以不用包含在聚 ...

  3. QTableWidget行选中/删除/添加行

    1  均分各列 tableWidget->horizontalHeader()->setStretchLastSection(true); //就是这个地方 tableWidget-> ...

  4. GridView/DataGrid行单击和双击事件实现代码_.Net教程

    功能: 单击选中行,双击打开详细页面 说明:单击事件(onclick)使用了 setTimeout 延迟,根据实际需要修改延迟时间 ;当双击时,通过全局变量 dbl_click 来取消单击事件的响应  ...

  5. TreeViewItem实现整行选中 (两种用法)

    用法一 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quo ...

  6. 支持行单击、双击事件的GridView和DataList控件(译)

    支持行单击.双击事件的GridView和DataList控件(译)         让GridView 和 DataList 控件响应鼠标单击.双击事件.并且,使用 ClientScript.Regi ...

  7. 在dbgrid中如何多行选中记录(ctl与shift均可用)

    在dbgrid中如何多行选中记录(ctl与shift均可用),设置dbgrid的dgmultiselect为true,只有ctl好用而shift不好用,如何使shift也好用 Dbgrid源代码:pr ...

  8. jquery-easyui的datagrid在checkbox多选时,行选中不正确应,去除高亮的解决方法

    jquery-easyui的datagrid在checkbox多选时,行选中不正确应,去除高亮的解决方法 工作中用到一个具有多选功能的easyui-datagrid在处理cell的点击事件时,不同 ...

  9. el-table合并行并自定义某一列或几列

    在el-table的官方组件中并没有看到具体的合并行或者列及自定义表格内容,于是就自己写了一个效果如下所示. 这种对左侧内容要求比较高,要求行合并,并要自定义一些内容.下面说一下具体方法及代码写法. ...

随机推荐

  1. linux命令(30):tail

    linux ---tail命令 linux中tail命令---用于查看文件内容 最基本的是cat.more和less. 1. 如果你只想看文件的前5行,可以使用head命令,如: head -5 /e ...

  2. 使用 esxtop 识别存储性能问题

    可以使用交互式 esxtop 实用程序提供连接到 VMware ESX 主机的各种设备的 I/O 衡量指标. 使用 esxtop 配置监控 要监控每个 HBA 的存储性能,请执行以下操作: 通过在命令 ...

  3. 一款基于jquery的手风琴图片展示效果

    今天要给大家分享一款基于jquery的手风琴图片展示效果.这款图片的展示效果鼠标经过前是灰色的,当鼠标经过时图片变大且变为彩色.效果图如下: 在线预览   源码下载 实现的代码. html代码: &l ...

  4. u-boot 2016.05 添加u-boot cmd

    记录一下如何在u-boot 添加一个自己想要的命令. 首先来看一下宏,include/command.h 218 #define U_BOOT_CMD(_name, _maxargs, _rep, _ ...

  5. FusionCharts JavaScript API - Events 全局事件处理

    FusionCharts JavaScript API - Events 全局事件处理 Home > FusionCharts XT and JavaScript > API Refere ...

  6. Ubuntu12.10 使用JLink连接开发板用arm-gdb调试ARM程序

    Part1 环境搭建和工具安装 1.1 设置交叉编译环境 安装相关的编译工具: sudo apt-get install build-essential gcc-arm-linux-gnueabi 这 ...

  7. CentOS 6编译安装yum和配置常用的yum源

    安装环境:VPS,CentOS 6 + devel包 一.安装相应的软件 1.安装python 下载Python源码包 [root@akinlau ~]# wget http://www.python ...

  8. 轻量级ORM框架Dapper应用三:使用Dapper实现In操作

    IN 操作符允许我们在 WHERE 子句中规定多个值. 本篇文章中,还是使用和上篇文章中同样的实体类和数据库,Dapper使用in操作符的代码如下: using System; using Syste ...

  9. xshell用ssh连接VMware中的ubuntu

    SSH分客户端openssh-client和openssh-server如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudo apt-ge ...

  10. hibernate不调用save也保存上了

    List<Instrument> insts = instService.search(search); if (insts.size() == 1) { Instrument inst ...