1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. <meta name="keywords" content="jquery,ui,easy,easyui,web">
  5. <meta name="description" content="easyui help you build your web page easily!">
  6. <title>jQuery EasyUI Demo</title>
  7. <link rel="stylesheet" type="text/css" href="http://www.jeasyui.net/Public/js/easyui/themes/default/easyui.css">
  8. <link rel="stylesheet" type="text/css" href="http://www.jeasyui.net/Public/js/easyui/themes/icon.css">
  9. <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
  10. <script type="text/javascript" src="http://www.jeasyui.net/Public/js/easyui/jquery.easyui.min.js"></script>
  11. <script>
  12. function getSelected(){
  13. var row = $('#tt').datagrid('getSelected');
  14. if (row){
  15. alert('Item ID:'+row.itemid+"\nPrice:"+row.listprice);
  16. }
  17. }
  18. function getSelections(){
  19. var ids = [];
  20. var rows = $('#tt').datagrid('getSelections');
  21. for(var i=0; i<rows.length; i++){
  22. ids.push(rows[i].itemid);
  23. }
  24. alert(ids.join('\n'));
  25. }
  26. function upRow(){
  27. var row = $('#tt').datagrid('getSelected');
  28. var rowindex = $('#tt').datagrid('getRowIndex',row);
  29. //alert(rowindex);
  30. if(rowindex === 0) {return; }
  31. $('#tt').datagrid('insertRow',{index:rowindex-1,row});
  32. $('#tt').datagrid('deleteRow',rowindex+1);
  33. }
  34. function allRows(){
  35. var rows = $('#tt').datagrid('getRows');
  36. alert(rows.length);
  37. for(var i=0; i<rows.length; i++){
  38. alert(rows[i].itemid);
  39. }
  40. }
  41. </script>
  42. </head>
  43. <body>
  44. <h1>DataGrid</h1>
  45. <div style="margin-bottom:20px">
  46. <a href="#" onclick="getSelected()">GetSelected</a>
  47. <a href="#" onclick="getSelections()">GetSelections</a>
  48. <a href="#" onclick="upRow()">upRow</a>
  49. <a href="#" onclick="allRows()">all rows</a>
  50. </div>
  51. <table id="tt" class="easyui-datagrid" style="width:600px;height:250px"
  52. url="data/datagrid_data.json"
  53. data-options="singleSelect:true"
  54. title="Load Data" iconCls="icon-save" fitColumns="true">
  55. <thead>
  56. <tr>
  57. <th field="itemid" width="80">Item ID</th>
  58. <th field="productid" width="80">Product ID</th>
  59. <th field="listprice" width="80" align="right">List Price</th>
  60. <th field="unitcost" width="80" align="right">Unit Cost</th>
  61. <th field="attr1" width="150">Attribute</th>
  62. <th field="status" width="60" align="center">Stauts</th>
  63. </tr>
  64. </thead>
  65. </table>
  66. </body>
  67. </html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="jquery,ui,easy,easyui,web">
<meta name="description" content="easyui help you build your web page easily!">
<title>jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.net/Public/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.net/Public/js/easyui/themes/icon.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.net/Public/js/easyui/jquery.easyui.min.js"></script>
<script>
function getSelected(){
var row = $('#tt').datagrid('getSelected');
if (row){
alert('Item ID:'+row.itemid+"\nPrice:"+row.listprice);
}
}
function getSelections(){
var ids = [];
var rows = $('#tt').datagrid('getSelections');
for(var i=0; i<rows.length; i++){
ids.push(rows[i].itemid);
}
alert(ids.join('\n'));
}
    function upRow(){
var row = $('#tt').datagrid('getSelected');
var rowindex = $('#tt').datagrid('getRowIndex',row);
//alert(rowindex);
if(rowindex === 0) {return; }
$('#tt').datagrid('insertRow',{index:rowindex-1,row});
$('#tt').datagrid('deleteRow',rowindex+1);
}
function allRows(){
var rows = $('#tt').datagrid('getRows');
alert(rows.length);
for(var i=0; i&lt;rows.length; i++){
alert(rows[i].itemid);
}
}
&lt;/script&gt;

</head>

<body>

<h1>DataGrid</h1>

<div style="margin-bottom:20px">

<a href="#" onclick="getSelected()">GetSelected</a>

<a href="#" onclick="getSelections()">GetSelections</a>

<a href="#" onclick="upRow()">upRow</a>

<a href="#" onclick="allRows()">all rows</a>

</div>

<table id="tt" class="easyui-datagrid" style="width:600px;height:250px"

url="data/datagrid_data.json"

data-options="singleSelect:true"

title="Load Data" iconCls="icon-save" fitColumns="true">

<thead>

<tr>

<th field="itemid" width="80">Item ID</th>

<th field="productid" width="80">Product ID</th>

<th field="listprice" width="80" align="right">List Price</th>

<th field="unitcost" width="80" align="right">Unit Cost</th>

<th field="attr1" width="150">Attribute</th>

<th field="status" width="60" align="center">Stauts</th>

</tr>

</thead>

</table>

</body>

</html>

  1. data-options="singleSelect:true"
data-options="singleSelect:true"

实现单行选择.

参考数据:

  1. {"total":28,"rows":[
  2. {"productid":"FI-SW-01","unitcost":10.00,"status":"P","listprice":16.50,"attr1":"Large","itemid":"EST-1"},
  3. {"productid":"K9-DL-01","unitcost":12.00,"status":"P","listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"},
  4. {"productid":"RP-SN-01","unitcost":12.00,"status":"P","listprice":18.50,"attr1":"Venomless","itemid":"EST-11"},
  5. {"productid":"AV-CB-01","unitcost":92.00,"status":"P","listprice":193.50,"attr1":"Adult Male","itemid":"EST-18"}
  6. ]}
{"total":28,"rows":[
{"productid":"FI-SW-01","unitcost":10.00,"status":"P","listprice":16.50,"attr1":"Large","itemid":"EST-1"},
{"productid":"K9-DL-01","unitcost":12.00,"status":"P","listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"},
{"productid":"RP-SN-01","unitcost":12.00,"status":"P","listprice":18.50,"attr1":"Venomless","itemid":"EST-11"},
{"productid":"AV-CB-01","unitcost":92.00,"status":"P","listprice":193.50,"attr1":"Adult Male","itemid":"EST-18"}
]}

下移同理.

datagrid实现行的上移和下移(转)的更多相关文章

  1. datagrid实现行的上移和下移

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  2. Extjs中grid行的上移和下移

    一.将up和down按钮放到tbar中,然后选中grid行即可实现上移和下移 var up = new Ext.Action({ text : 'Up', icon : 'up.png',//或者添加 ...

  3. JQuery实现表格行的上移、下移、删除、增加

    <%@ page language="java" import="java.util.*" pageEncoding="GBK"%&g ...

  4. jquery easyui datagrid实现单行的上移下移,以及保存移动的结果

    1.实现行的上移.下移. 说明: 1.1 通过datagrid生成的表格有固定的格式,比如,表格div的class名是datagrid-view.比如每一行tr都有id和datagrid-row-in ...

  5. Lind.DDD.Domain.ISortBehavor~上移与下移

    在进行列表排序时,有个“上移”和“下移”操作,这个一般在内存里完成,然后统一提交到数据库中,对于上移与下移的设计,大叔在LIND.DDD.DOMAIN里有一个ISortBehavor接口,主要是说,如 ...

  6. jquery实现标签上移、下移、置顶

    eg:如在后台的标签列表中,实现上移.下移.置顶功能 思路: 1.先用到的克隆方法.clone(true): 即把当前要移动的项先保存好,备于后用. 2.找到当前标签所对应的相关元素及其相关方法: 如 ...

  7. js上移、下移、置顶、置底功能实现

    实现页面上列表内容上移.下移.置顶.置底 功能,主要实现思路是节点操作,比如说:上移,直接把点击项移动到前一个节点,以此类推,当然实际代码实现还要加些判断,如当前点击操作项是否已经是置底或置底了,如果 ...

  8. ListView上移 和下移

              有问题 //ListBox选中的项目移动到第1位   Listbox1.Items.Move(ListBox1.ItemIndex,0); //ListView选中的项目移动到第1 ...

  9. Easyui Datagrid rownumbers行号四位、五位显示不完全的解决办法

    Easyui Datagrid rownumbers行号四位.五位显示不完全的解决办法(引) 方法一: 相信很多人在使用easyui的时候都遇到过这个问题,当我们设置成显示Rownumber的时候,你 ...

随机推荐

  1. .net控件Radiobuttonlist的简单应用

    1.radiobuttonlist 通过RepeatDirection属性控制改控件的显示方向是纵向还是横向. 2.radiobuttonlist有一个重要的时间叫OnSelectedIndexCha ...

  2. EventBus 事件总线之我的理解

    用例:假设公司发布了一个公告 需要通过短信 和 邮件分别2种方式 通知员工 1:首先我们建立领域模型 /// <summary> /// 领域核心基类 /// </summary&g ...

  3. Java之戳中痛点 - (6)避免类型自动转换,例如两个整数相除得浮点数遇坑

    先来看一个例子: package com.test; public class calculate { /** * 光速30万公里/秒 */ public static final int LIGHT ...

  4. Spring定时器实现(一)

    Spring定时器简单应用实现,如下: 首先.Spring配置文件: <?xml version="1.0" encoding="UTF-8"?> ...

  5. spring 的单例模式

    singleton---单例模式 单例模式,在spring 中其实是scope(作用范围)参数的缺省设定值每个bean定义只生成一个对象实例,每次getBean请求获得的都是此实例 单例模式分为饿汉模 ...

  6. Android保存图片到本地相册

    好久没有写东西了.备份下知识吧.免得忘记了 . 首先贴一段代码 --  这个是先生成一个本地的路径,将图片保存到这个文件中,然后扫描下sd卡.让系统相册重新加载下 .缺点就是只能保存到DCIM的文 件 ...

  7. Swift4 Json

    swift4 带来了原生的json解析,它们分别是 JSONDecoder和JSONEncoder,使用起来还算方便,不过为了更方便,我把它们又进行了简单的封装: class JsonHelper { ...

  8. TASKCTL敏捷调度理念的诠释

    功能完整是基本,简单易用才是王道,这就是TASKCTL对敏捷的朴素定义.功能少,怎么复杂也会简单:而功能体系完整,怎么简单也会复杂.因此,简单与复杂是相对的,而TASKCTL正是追求那种在功能完整不可 ...

  9. ASP.NET 导出excel文件出现乱码的解决办法

    string html =TABLE ;//<table>标签,可以是多张表string modified = Regex.Replace(html, "<table &g ...

  10. java中什么样的对象能够进入老年代

    1.大对象:所谓的大对象是指需要大量连续内存空间的java对象,最典型的大对象就是那种很长的字符串以及数组,大对象对虚拟机的内存分配就是坏消息,尤其是一些朝生夕灭的短命大对象,写程序时应避免. 2.长 ...