实现如下功能:

代码:

<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. 【转】MapReduce读取lzo文件

    1.读lzo文件 需要添加以下代码,并导入lzo相关的jar包 job.setInputFormatClass(LzoTextInputFormat.class); 2.写lzo文件 lzo格式默认是 ...

  2. C#中实现Windows系统流氓监控程序

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. pthread_cond_wait()函数的详解

    http://hi.baidu.com/tjuer/item/253cc6d66b921317d90e4483 了解 pthread_cond_wait() 的作用非常重要 -- 它是 POSIX 线 ...

  4. springMVC demo搭建

    1.使用idea新建一个基于maven的web项目,参考 http://www.cnblogs.com/winkey4986/p/5279820.html 2.采取了比较偷懒的配置方法,只配置了一个D ...

  5. win10无法访问局域网共享文件?(因微软账户和本地账户登陆问题导致)

    1 笔记本系统win10 X64企业版,其中一文件夹已设置为“共享”.本地帐号登录系统. 2 平板电脑系统win8.1 X64专业版,可以顺畅的访问笔记本的共享文件.微软帐号登录系统. 3 平板电脑系 ...

  6. C++实现通讯信息管理系统

    通讯信息管理系统 可以实现通讯信息的增加,浏览,删除,修改,查询,保存和读取功能.该系统还限制了通讯信息的条数(limit变量来限制) 文件放置结构: 具体实现代码如下: #include<io ...

  7. 将sqlServer上的数据库文件进行盘目的迁移

    在数据库客户端创建数据库时要改为.mdf文件,因为附加问价时附加的是.mdf文件: 在里选中相应的数据库 右键->任务-分离 在 剪切到相应的想放置的盘目. 例如迁移到E盘下: 在数据库-> ...

  8. 超多的CSS3圆角渐变网页按钮

    <!DOCTYPE html><head><title>超多的CSS3圆角渐变按钮</title><style type="text/c ...

  9. 关于Cocos2d-x中根据分数增加游戏难度的方法

    1.GameScene.h中声明一些分数边界值 //level提升所需的分数 enum LevelUp_Score { Level1Up_Score = , Level2Up_Score = , Le ...

  10. Runtime是什么?

    在看 RPC 的概念模型与实现解析 的时候,看到图片上有Runtime,又想到见过很多Runtime之类的东西,所以就想弄明白这到底是个什么东西. (因为是程序名,所以根本没想到代码的“编译-运行”~ ...