Extjs4实现两个GridPanel之间数据拖拽功能具体方法

(编辑:jimmy 日期: 2024/10/10 浏览:2)

1、之前在winForm上有看过在选择数据时会将一些数据放在待选框中,而用户可以将想要选择的数据放到备选框中,那么如何用Extjs实现类似功能,我们选择用两个gridPanel来模拟其中的备选框和待选框。如下图所示:

Extjs4实现两个GridPanel之间数据拖拽功能具体方法

定义代码如下:
复制代码 代码如下:
         {
               xtype:'gridpanel',
               multiSelect: true,
                id:'staff',
                x: 5,
             y: 0,
             height: 205,
             width: 260,
                viewConfig: { 
                    plugins: { 
                         ptype: 'gridviewdragdrop', 
                         dragGroup: 'firstGridDDGroup', 
                       dropGroup: 'secondGridDDGroup' 
               },
               listeners: { 
                  drop: function(node, data, dropRec, dropPosition) { 
                      var dropOn = dropRec ? ' ' + dropPosition + ' ' + dropRec.get('name') : ' on empty view';
                  } 
               } 
           },
            store:StaffData, //加载数据的store
            columns: columns, 
            stripeRows: true, 
            title: '从业人员', 
            margins: '0 2 0 0' 
            },
           {
            xtype:'gridpanel',
            id:'admin',
            x: 280,
           y: 0,
           height: 205,
           width: 260,
          viewConfig: { 
              plugins: { 
                  ptype: 'gridviewdragdrop', 
                  dragGroup: 'secondGridDDGroup', 
                  dropGroup: 'firstGridDDGroup' 
              }, 
              listeners: { 
                  drop: function(node, data, dropRec, dropPosition) { 
                      var dropOn = dropRec ? ' ' + dropPosition + ' ' + dropRec.get('name') : ' on empty view';
                  } 
              } 
          }, 
          store:AdminData, 
          columns:columns, 
          stripeRows:true, 
          title:'管理员', 
          margins:'0 0 0 3'
           }

这样我们在拖拽时即可以将数据存储在所对应的store中,需要的时候从store取出数据即可。

一句话新闻

高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。