zoukankan      html  css  js  c++  java
  • 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 >




  • 相关阅读:
    性能优化方法
    JSM的topic和queue的区别
    关于分布式事务、两阶段提交协议、三阶提交协议
    大型网站系统与Java中间件实践读书笔记
    Kafka设计解析:Kafka High Availability
    kafka安装和部署
    String和intern()浅析
    JAVA中native方法调用
    Java的native方法
    happens-before俗解
  • 原文地址:https://www.cnblogs.com/babyhhcsy/p/3229951.html
Copyright © 2011-2022 走看看