实现如下功能:

代码:

<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. hdoj1171 Big Event in HDU

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  2. TagsView.vue

    1.TagsView.vue <template> <div class="tags-view-container"> <scroll-pane cl ...

  3. uml 符号关系示意

    类(Class) 类(图A)是对象的蓝图,其中包含3个组成部分.第一个是Java中定义的类名.第二个是属性(attributes).第三个是该类提供的方法.属性和操作之前可附加一个可见性修饰符.加号( ...

  4. jquery全部版本

    http://www.jb51.net/zt/jquerydown.htm 这个地方实时更新jquery版本

  5. xml大项目,增删改查

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

  6. 【WampServer笔记】常用文件及其配置

    用的集成工具是 www.wampserver.com WampServer = Windows操作系统 + Apache服务器 + MySQL数据库 + Php服务器脚本 WampServer工具(集 ...

  7. am335x ti SDK6.0 kernel 时钟源码文件记录

    源码流程记录 板级文件开始 // arch/arm/mach-omap2/board-aplex_cmi_at101.c MACHINE_START(APLEX_CMI_AT101, "ap ...

  8. pthread_setschedparam

    #include <stdlib.h> #include <pthread.h> #include <stdio.h> #include <sched.h&g ...

  9. Android——Button的颜色

    .xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...

  10. Yii CDbCriteria常用用法

    $criteria = new CDbCriteria;$criteria->compare('name',$this->name,true,'OR'); //like部分匹配//$cri ...