• ExtJs grid可拖拽行


    ExtJS可拖拽功能

    步骤:
    在定义grid的时候设置    enableDragDrop: true 可以拖拽的功能
    在定义一个dropTarget
    如果获得用户选择了几行;
    var rows = data.selections;
    得到用户拖动到第几行
    var index = dd.getDragData(e).rowIndex;
     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;
                }
                // 修改store
                for(i = 0; i < rows.length; i++) {
                    var rowData = rows[i];
                    if(!this.copy) store.remove(rowData);
                    store.insert(index, rowData);
                }
            }
        });
     
    < html >
         < head >
             < meta   http-equiv = "Content-Type"   content = "text/html; charset=gbk" >
             < title > 03.grid </ title >
               < link   rel = "stylesheet"   type = "text/css"   href = "../ext3.2/resources/css/ext-all.css"   />
             < script   type = "text/javascript"   src = "../ext3.2/adapter/ext/ext-base.js" ></ script >
             < script   type = "text/javascript"   src = "../ext3.2/ext-all.js" ></ script >
             < script   type = "text/javascript" >
    Ext.onReady( function (){
         var  cm =  new  Ext.grid.ColumnModel([
            {header: '编号' ,dataIndex: 'id' },
            {header: '名称' ,dataIndex: 'name' },
            {header: '描述' ,dataIndex: 'descn' }
        ]);
         var  data = [
            [ '1' , 'name1' , 'descn1' ],
            [ '2' , 'name2' , 'descn2' ],
            [ '3' , 'name3' , 'descn3' ],
            [ '4' , 'name4' , 'descn4' ],
            [ '5' , 'name5' , 'descn5' ]
        ];
         var  store =  new  Ext.data.Store({
            proxy:  new  Ext.data.MemoryProxy(data),
            reader:  new  Ext.data.ArrayReader({}, [
                {name:  'id' },
                {name:  'name' },
                {name:  'descn' }
            ])
        });
        store.load();
         var  grid =  new  Ext.grid.GridPanel({
            autoHeight:  true ,
            renderTo:  'grid' ,
            store: store,
            cm: cm,
            enableDragDrop:  true
         });
         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 ;
                }
                 // 修改store
                for (i = 0; i < rows.length; i++) {
                     var  rowData = rows[i];
                     if (! this .copy) store.remove(rowData);
                    store.insert(index, rowData);
                }
            }
        });
    });
             </ script >
         </ head >
         < body >
           
             < div   id = "grid" ></ div >
         </ body >
    </ html >




  • 相关阅读:
    BreakRoleInheritance在多线程情况下调用的问题
    如何通过IAlertNotifyHandler来自定义Alert Email
    SPField的几种name的释疑
    使用SQL语句得到存储过程的实现
    在C# 中使用反射调用internal的属性
    程序安装时检查是否已经安装.NETFramework
    biztalk
    什么是Biztalk?
    分页存储过程
    SQL SERVER 2005 CLR 部署UDT,Triggers,Functions,Procedure,Aggregates
  • 原文地址:https://www.cnblogs.com/babyhhcsy/p/3229951.html
Copyright © 2020-2023  润新知