加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

extjs4.0----Grid To Grid拖拽示例

发布时间:2020-12-15 04:50:51 所属栏目:百科 来源:网络整理
导读:图示: ? ?js: [javascript] ? view plain copy script?type= "text/javascript" ?? ?????? ????Ext.require([?? ???????? 'Ext.grid.*' ,?? ???????? 'Ext.data.*' ,?? ???????? 'Ext.dd.*' ?? ????]);?? ????Ext.define( 'DataObject' ,?{?? ????????exte

图示:

?

?js:

[javascript]? view plain copy
  1. <script?type="text/javascript">??
  2. ??????
  3. ????Ext.require([??
  4. ????????'Ext.grid.*',??
  5. ????????'Ext.data.*',??
  6. ????????'Ext.dd.*'??
  7. ????]);??
  8. ????Ext.define('DataObject',?{??
  9. ????????extend:?'Ext.data.Model',108); color:inherit; line-height:18px"> ????????fields:?['name',?'column1',?'column2']??
  10. ????});??
  11. ??????
  12. ????Ext.onReady(function(){??
  13. ????????var?myData?=?[??
  14. ????????????{?name?:?"娜姐",?column1?:?"25",?column2?:?"3"?},248); line-height:18px"> ????????????{?name?:?"船长",?column1?:?"24",?column2?:?"2"?},108); color:inherit; line-height:18px"> ????????????{?name?:?"傻妞",?column1?:?"23",248); line-height:18px"> ????????????{?name?:?"阿呆",108); color:inherit; line-height:18px"> ????????????{?name?:?"猫猫",?column2?:?"3"?}??
  15. ????????];??
  16. ????????//?create?the?data?store??
  17. ????????var?firstGridStore?=?Ext.create('Ext.data.Store',248); line-height:18px"> ????????????model:?'DataObject',108); color:inherit; line-height:18px"> ????????????data:?myData??
  18. ????????});??
  19. ????????//?Column?Model?shortcut?array??
  20. var?columns?=?[??
  21. ????????????{text:?"姓名",?flex:?1,?sortable:?true,?dataIndex:?'name'},248); line-height:18px"> ????????????{text:?"年龄",?width:?70,?dataIndex:?'column1'},108); color:inherit; line-height:18px"> ????????????{text:?"水龄",?dataIndex:?'column2'}??
  22. //?declare?the?source?Grid??
  23. var?firstGrid?=?Ext.create('Ext.grid.Panel',248); line-height:18px"> ????????????multiSelect:? ????????????viewConfig:?{??
  24. ????????????????plugins:?{??
  25. ????????????????????ptype:?'gridviewdragdrop',248); line-height:18px"> ????????????????????dragGroup:?'firstGridDDGroup',108); color:inherit; line-height:18px"> ????????????????????dropGroup:?'secondGridDDGroup'??
  26. ????????????????},??
  27. ????????????????listeners:?{??
  28. ????????????????????drop:?function(node,?data,?dropRec,?dropPosition)?{??
  29. ????????????????????????var?dropOn?=?dropRec???'?'?+?dropPosition?+?'?'?+?dropRec.get('name')?:?'?on?empty?view';??
  30. ????????????????????????//Ext.example.msg("Drag?from?right?to?left",?'Dropped?'?+?data.records[0].get('name')?+?dropOn);??
  31. ????????????????????}??
  32. ????????????????}??
  33. ????????????},??
  34. ????????????store????????????:?firstGridStore,108); color:inherit; line-height:18px"> ????????????columns??????????:?columns,248); line-height:18px"> ????????????stripeRows???????:? ????????????title????????????:?'待选',248); line-height:18px"> ????????????margins??????????:?'0?2?0?0'??
  35. ????????});??
  36. var?secondGridStore?=?Ext.create('Ext.data.Store',248); line-height:18px"> ????????????model:?'DataObject'??
  37. //?create?the?destination?Grid??
  38. var?secondGrid?=?Ext.create('Ext.grid.Panel',?{??
  39. ????????????????????dragGroup:?'secondGridDDGroup',108); color:inherit; line-height:18px"> ????????????????????dropGroup:?'firstGridDDGroup'??
  40. //Ext.example.msg("Drag?from?left?to?right",248); line-height:18px"> ????????????store????????????:?secondGridStore,108); color:inherit; line-height:18px"> ????????????title????????????:?'已选',248); line-height:18px"> ????????????margins??????????:?'0?0?0?3'??
  41. //Simple?'border?layout'?panel?to?house?both?grids??
  42. var?displayPanel?=?Ext.create('Ext.Panel',108); color:inherit; line-height:18px"> ????????????width????????:?650,248); line-height:18px"> ????????????height???????:?300,108); color:inherit; line-height:18px"> ????????????layout???????:?{??
  43. ????????????????type:?'hbox',108); color:inherit; line-height:18px"> ????????????????align:?'stretch',248); line-height:18px"> ????????????????padding:?5??
  44. ????????????renderTo:?Ext.getBody(),108); color:inherit; line-height:18px"> ????????????defaults?????:?{?flex?:?1?},?//auto?stretch??
  45. ????????????items????????:?[??
  46. ????????????????firstGrid,248); line-height:18px"> ????????????????secondGrid??
  47. ????????????],248); line-height:18px"> ????????????dockedItems:?{??
  48. ????????????????xtype:?'toolbar',248); line-height:18px"> ????????????????dock:?'bottom',108); color:inherit; line-height:18px"> ????????????????items:?['->',?//?Fill??
  49. ????????????????{??
  50. ????????????????????text:?'全选',248); line-height:18px"> ????????????????????handler:? ????????????????????????firstGridStore.removeAll();??
  51. ????????????????????????secondGridStore.loadData(myData);??
  52. ????????????????????}??
  53. ????????????????},{??
  54. ????????????????????text:?'取消',108); color:inherit; line-height:18px"> ????????????????????handler:?function(){??
  55. ????????????????????????firstGridStore.loadData(myData);??
  56. ????????????????????????secondGridStore.removeAll();??
  57. ????????????????}]??
  58. ????????????}??
  59. ??
  60. ????</script>??

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读