一、将up和down按钮放到tbar中,然后选中grid行即可实现上移和下移

 var up = new Ext.Action({
text : 'Up',
icon : 'up.png',//或者添加样式iconCls
disabled : true,
handler : function() {
var record = grid.getSelectionModel().getSelected();
if (record) {
var index = grid.store.indexOf(record);
if (index > 0) {
grid.store.removeAt(index);
grid.store.insert(index - 1, record);
grid.getView().refresh(); // refesh the row number
grid.getSelectionModel().selectRow(index - 1);
}
} else {
Ext.Msg.alert('Warning', 'Please select one item!');
}
}
}); var down = new Ext.Action({
text : 'Down',
icon : 'down.png',//或者添加样式iconCls
disabled : true,
handler : function() {
var record = grid.getSelectionModel().getSelected();
if (record) {
var index = grid.store.indexOf(record);
if (index < grid.store.getCount() - 1) {
grid.store.removeAt(index);
grid.store.insert(index + 1, record);
grid.getView().refresh(); // refesh the row number
grid.getSelectionModel().selectRow(index + 1);
}
} else {
Ext.Msg.alert('Warning', 'Please select one item!');
}
}
});

二、grid行的拖动实现上移和下移

 var grid = new Ext.grid.GridPanel({
layout : 'fit',
loadMask : true,
enableDragDrop : true,
ddGroup: "GridDD",
viewConfig : {
forceFit : true,
enableRowBody : true,
showPreview : true,
cls:"x-grid-empty",
emptyText: _('ID_NO_RECORDS_FOUND')
},
listeners : {
'afterrender' : function() {
var ddrow = new Ext.dd.DropTarget(grid.container, {
ddGroup : 'GridDD',
copy : false,
notifyDrop : function(dd, e, data) {
var rows = data.selections;
var index = dd.getDragData(e).rowIndex;
if(typeof(index) == "undefined") return;
for(i = 0; i < rows.length; i++) {
if(!this.copy) {
grid.getStore().remove(rows[i]);
grid.getStore().insert(index, rows[i]);
grid.view.refresh();
}
}
}
});
}
}
});

Extjs中grid行的上移和下移的更多相关文章

  1. EXTJS中grid的数据特殊显示,不同窗口的数据传递

    //EXTJS中grid的数据特殊显示renderer : function(value, metaData, record, rowIndex, colIndex, store, view) { v ...

  2. Extjs中grid表格中去掉红三角

    在编辑Extjs的gridpanel的时候,数据有错误或是修改在每个单元格上都会出现红色的小三角,在每个列上面可以配置allowBlank: false来标识这个不可以为空 有的时候在保存数据时如果不 ...

  3. extjs中grid中行内文本或图片居中显示

    我是看了网上写的方法调试自己的代码来实现的,实现的方式是当加载store数据时改变grid的行样式,源码如下: html代码: <div id="weatherP_grid-body& ...

  4. Extjs中grid前端分页使用PagingMemoryProxy【二】

        在项目中遇到Grid前端分页,本人也是刚接触extjs没多久,为了实现效果,一直找了很久才实现出来,对于代码中的一些也不能详细的说明出来, 不知道能不能帮助到遇到同样问题的朋友,所以将例子代码 ...

  5. Extjs中grid 的ColumnModel 属性配置

    一, 用数组的方式配置ColumnModel var colModel = new Ext.grid.ColumnModel([ { header:'编号', dataIndex:'id',width ...

  6. 64. Extjs中grid 的ColumnModel 属性配置

    转自:https://blog.csdn.net/u011530389/article/details/45821945 本文导读:Ext.grid.ColumnModel 该类用于定义表格的列模型, ...

  7. ASP.Net中的TreeView控件中对节点的上移和下移操作

    Web中的TreeView中的没有PreNode和NextNode属性. 但它的集合属性中有一个IndexOf属性,从而能够找到它的前一个节点知后一个节点. TreeView中要么只有一个根节点:要么 ...

  8. NSS_04 extjs中grid接收datetime类型参数列

    今天在做用户列表时发现, asp.net mvc3的控制器在返回JsonResult结果时, 会把对象内的DateTime类型成员,解析为类似于\/Date(1238606590509)\/的格式 , ...

  9. Extjs 改变grid行的背景颜色

    ## Ext grid 改变行背景色 Ext.util.CSS.createStyleSheet('.ts {background:#9a9a9bc2;}');//单独创建css样式 { xtype: ...

随机推荐

  1. JS的this本质

    1.this究竟为何物? 1.1 全局上下文(Global context ) 在全局运行上下文中(在任何函数体外部),this 指代全局对象window,无论是否在严格模式下. alert(this ...

  2. Source Insight 显示中文乱码

    Source Insight 3.X utf8支持插件震撼发布 继上次SI多标签插件之后,因为公司内部编码改为utf8编码,因此特意做了这个Source Insight 3.X utf8插件. 下载地 ...

  3. 下拉框点链接js

    $("#input_text").click(function(){ $("#input_fonts").show(); }); $("#input_ ...

  4. WINDOWS 2008 SERVER域用户自动登陆

    The user I wanted to auto-logon as didn’t have a password, this reg hack worked instead: HKEY_LOCAL_ ...

  5. linux zip 命令详解

    功能说明:压缩文件. 语 法:zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <工作目录>][-ll][-n <字尾字符串>][-t <日期时 ...

  6. [dp]HDOJ4960 Another OCD Patient

    题意: 给一个n, 第二行给n堆的价值v[i], 第三行给a[i].  a[i]表示把i堆合在一起需要的花费. 求把n堆变成类似回文的 需要的最小花费. 思路: ①记忆化搜索 比较好理解... dp[ ...

  7. 【HDOJ】1075 What Are You Talking About

    map,STL搞定. #include <iostream> #include <string> #include <cstdio> #include <cs ...

  8. mingw32 下编译 zlib

    cp win32/makefile.gcc makefile.gcc make -f makefile.gcc make install -f Makefile.gcc INCLUDE_PATH=/m ...

  9. MVC——数据库增删改查(Razor)

    一.显示信息 .Models(模板) private MyDBDataContext _context = new MyDBDataContext(); //定义一个变量取出所有数据 public L ...

  10. windows播放声音

    一般播放MP3常见的有两种方法,一种是自己解码,另外一种用系统的库,比如MCI,当然如果可以用控件直接用个控件会更方便. 1.      使用mci #include <windows.h> ...