easyui datagrid 列拖拽2
1、拖动前
2、拖动中
3、拖动后
5、代码1
- $("#corp-grid").datagrid({
- title:"泥头车企业管理",
- toolbar:"#corp-grid-toolbar",
- border:false,
- fit:true,
- width:$(window).width()-252,
- columns:[[
- {field:"ckb",checkbox:true},
- {field:"corpName",title:"企业名称",width:200,halign:"center",align:"center",resizable:true},
- {field:"linkedCorpName",title:"挂靠深圳企业名称",width:200,halign:"center",align:"center",resizable:true},
- {field:"corpType",title:"企业类型",width:80,align:"center",resizable:false},
- {field:"businessScope",title:"经营范围",width:80,align:"center",resizable:false},
- {field:"effectiveDate",title:"有效日期",width:80,align:"center",resizable:false},
- {field:"opePeriod",title:"营业期限",width:80,align:"center",resizable:false},
- {field:"ifLocal",title:"是否本地",width:80,align:"center",resizable:false},
- {field:"state",title:"有效状态",width:80,align:"center",resizable:false}
- ]],
- //striped:true,
- fitColumns:true,
- //autoRowHeight:true,
- rownumbers:false,
- singleSelect:false,
- ctrlSelect:true,
- pagination:true,
- pageSize:10,
- pageList:[5,10,15,20,25,30],
- sortName:"corpId",
- sortOrder:"desc",
- url:"corp_getInfoList.action",
- method:"post",
- loadMsg:"加载数据中,请稍后",
- onDblClickRow:function(rowIndex, rowData){
- openDialog({
- type:"view",
- title:"泥头车企业信息查看",
- width:800,
- height:400,
- maximizable:true,
- href:"BaseInfo/Corp/CorpInfoView.html"
- });
- },
- onRowContextMenu:function(e, rowIndex, rowData){
- e.preventDefault();
- $(this).datagrid("unselectAll");
- $(this).datagrid("selectRow", rowIndex);
- $("#corp-menu").menu("show",{
- left:event.pageX,
- top:event.pageY
- });
- }
- }).datagrid("columnMoving");
6.代码2
- $.extend($.fn.datagrid.methods,{
- columnMoving:function(jq){
- return jq.each(function(){
- var grid = this;
- var directionDiv = $("<div></div>");
- directionDiv.hide();
- $("body").append(directionDiv);
- $(grid).datagrid("getPanel")
- .find(".datagrid-header td[field]:not(td[field='ckb'])").draggable({
- revert:true,
- cursor:"move",
- deltaX:10,
- deltaY:10,
- edge:10,
- proxy:function(source){
- var proxyEl = $("<div></div>");
- proxyEl.addClass("dg-proxy dg-proxy-error");
- proxyEl.text($(source).text());
- proxyEl.appendTo($("body"));
- return proxyEl;
- }
- }).droppable({
- accept:".datagrid-header td[field]",
- onDragOver:function(e,source){
- $(source).draggable("proxy").removeClass("dg-proxy-error").addClass("dg-proxy-right");
- $(".dg-hide-div").hide();
- var thisIndex = $(this).index();
- var sourceIndex = $(source).index();
- var className = null;
- var height = null;
- var thisOffset = null;
- var left = null;
- var top = null;
- height = $(this).height();
- if(sourceIndex > thisIndex){
- className = "dg-move-prev";
- thisOffset = $(this).offset();
- left = thisOffset.left;
- top = thisOffset.top;
- }else{
- className = "dg-move-next";
- if(thisIndex == $(this).parent().children(":last").index()){
- thisOffset = $(this).offset();
- left = thisOffset.left + $(this).width() - directionDiv.width();
- top = thisOffset.top;
- }else{
- thisOffset = $(this).next().offset();
- left = thisOffset.left - directionDiv.width();
- top = thisOffset.top;
- }
- }
- directionDiv.removeClass().addClass(className);
- directionDiv.css({height:height, left:left, top:top});
- directionDiv.show();
- },
- onDragLeave:function(e,source){
- $(source).draggable("proxy").removeClass("dg-proxy-right").addClass("dg-proxy-error");
- directionDiv.hide();
- },
- onDrop:function(e,source){
- directionDiv.remove();
- var thisIndex = $(this).index();
- var sourceIndex = $(source).index();
- var sourceCol = new Array();
- $(source).remove();
- $.each($(grid).datagrid("getPanel")
- .find(".datagrid-body tr"),function(index,obj){
- var sourceTd = $(obj).children("td:eq(" + sourceIndex + ")");
- sourceCol.push(sourceTd);
- sourceTd.remove();
- });
- var prev = sourceIndex > thisIndex;
- thisIndex = $(this).index();
- if(prev){
- $(this).before($(source));
- }else{
- $(this).after($(source));
- }
- $.each($(grid).datagrid("getPanel")
- .find(".datagrid-body tr"),function(index,obj){
- var thisTd = $(obj).children("td:eq(" + thisIndex + ")");
- if(prev){
- thisTd.before(sourceCol[index]);
- }else{
- thisTd.after(sourceCol[index]);
- }
- });
- $(grid).datagrid("columnMoving").datagrid("columnHiding");
- }
- });
- });
- }
- });
easyui datagrid 列拖拽2的更多相关文章
- easyui datagrid 列拖拽
首先easyui 它有提供了拖拽的功能Draggable,那我们就可以想 拖拽标题头到另外的标题头上面我们就对datagrid的columns重新绑定一次 并刷新datagrid这个功能不就行了? & ...
- easyui datagrid列拖拽
<script type="text/javascript"> var cols = [{ field: 'testName', title: '<span cl ...
- easyui datagrid 列隐藏和显示
easyui datagrid 列隐藏和显示 用js怎么控制列的显示和隐藏? 最佳答案 $('#grid').datagrid('hideColumn','列field');把hideColu ...
- js控制easyui datagrid列的显示和隐藏
easyui datagrid 列隐藏和显示 $('#grid').datagrid('hideColumn','列field'); //把hideColumn换成showColumn 即为显示列
- easyui树节点拖拽排序的存储过程
easyui树的拖拽排序功能 easyui树中有拖拽功能 树结构如下: 一个行政区域对应一个单位,一个单位对应多个部门,每个部门下有相关人员,功能要求: (1)行政区域没有子节点,点击text加载部门 ...
- 在 Element-UI 的 Table 组件上添加列拖拽效果
Element-UI 的 Table组件很强大,但是我们的需求更强大... 简单粗暴的来一发效果图: 一.数据驱动 传统的拖动效果,都是基于通过 mousedown.mousemove.mouseup ...
- 列拖拽顺序调整-sortable.js使用
最近在做一个单表统计功能,涉及到一个查询列配置,但是查询出来的列顺序,可以进行配置,通过写列的排序当然阔以,但是方法就不美丽了.所以,在网上搜了一下拖拽的组件,最终定位Sortable.js,简单易用 ...
- 让jquery easyui datagrid列支持绑定嵌套对象
嵌套对象是指返回的json数据,是对象的某个属性自带有属性.而我们恰恰又需要这个属性,默认情况下easyui的datagrid是不支持绑定嵌套对象的.比如:datagrid的field属性只能为fie ...
- easyUI datagrid 列宽自适应(简单 图解)(转)
响应数据格式: easyUI在html代码中结构: 发现了什么没有,我们的表头其实是一个td在td中有一个属性field那么我们就可以获得了; 以下就是自适应代码: //添加事件 function c ...
随机推荐
- android错误系列之导出数据库出错Failed to pull selection
使用效率检视工具traceView,在导出检测文件时,出现了“failed to pull a selection”问题,网上搜索了几篇文章,有的说,是因为导出超时,我将windows-->pr ...
- netdata linux环境下的安装
据说netdata监控很个性化,采用的显示方式也很漂亮,就来尝试安装.百度搜索到的安装教程的斑斑是1.0.顺藤摸瓜去wiki看了看,已经更新为1.4了,果断走起: 下载地址::https://gith ...
- HDU 2196 Computer (树dp)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2196 给你n个点,n-1条边,然后给你每条边的权值.输出每个点能对应其他点的最远距离是多少 ...
- 解决CSS各种IE各种兼容问题(Google解决方案)
google的 ie7 – js中是一个JavaScript库(解决IE与W3C标准的冲突的JS库),使微软的Internet Explorer的行为像一个Web标准兼容的浏览器,支持更多的W3C标准 ...
- extjs 点击复选框在表格中增加相关信息行
功能效果:点击复选框在表格中自动增加相关信息行,复选框取消则表格中内容自动删除 初始效果大概是这样~~~~~ // 定义初始 存放表格数据 var gridItems = []; //省份复选框 va ...
- 今天做php经典实例,发现,我是对的,面试官给我说错了
那是七月中下旬在乐元素公司面试,问了我问什么 $str = "Hellow {$res} world";这么写,我回答说 在字符串中插入复杂变量可以用花括号干起来把? 他告诉我 应 ...
- AS与JS相互通信(Flex中调用js函数)
转载自http://www.blogjava.net/Alpha/archive/2009/06/27/284373.html Flex中As调用Js的方法是: 1.导入包 (import f ...
- glibc strlen delphi pascal
From: Will DeWitt Jr. Subject: Fast strlen routine? NewsGroup: borland.public.delphi.language.basm D ...
- dmalloc 原文 翻译整理
http://blog.csdn.net/cardinal_508/article/details/5553387 L13 从快速入门开始(Quickstart) 这个库是一个文件中所有简化用法中最常 ...
- uva 11324 The Largest Clique(强连通分量缩点+DAG动态规划)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=sh ...