Ext中拖拽Tree2Grid , 清空表格拖拽失效的解决办法>.<

项目中需要实现导航树到表格的拖拽功能, 但是当我将表格中的记录逐个清空(gridStore.remove(rec))后, 发现节点信息再也拖不进来了,但是一次性清空(gridStore.removeAll())却没有任何问题 , 见图:

 

其后通过查询removeAll方法的源码:(ext版本3.4.0) ,发现了这一句,

 

        if (silent !== true) {  //  prevents write-actions when we just want to clear a store.     

 

                     this.fireEvent('clear', this, items);        }

 应该就是store的缓存没清的原因吧 ,下面是我的代码部分:

	/**
	 * 移出条目
	 */
	removeCurrentRec : function(){
		var selections = this.grid.getSelectionModel().selections;
		 if (selections.length == 0) {
	            Ext.MessageBox.alert("提示", "请选择一条的记录!");
	            return ;
	        } else if (selections.length != 1) {
	            Ext.MessageBox.alert("提示", "不能多选");
	            return ;
	        }
		this.grid.getStore().remove(selections.items[0]);
		//添加此,否则,拖拽功能就会失去效果
	          this.grid.getStore().fireEvent('clear', this.grid.getStore(), selections.item[0]);
	},
	
	/**
	 * 移出所有条目
	 */
	removeAllRec  : function(){
	     this.grid.getStore().removeAll();
	},

    最终可以随意删除,随意拖进了,效果见图:

   

  

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值