bind : {
title : ‘{tf_title} {selectedNames}‘ // 数据绑定到ModuleModel中的tf_title 和
// 选中记录的名称
},? ? ? ? 然后再在 ModuleModel.js中的data中增加属性:
selectedNames : ‘‘ //选中的记录的names显示在title上
?
?? ? ? Grid的记录选中事件在前几节中已经加了,仅仅要改动一下事件函数就能够了,改动ModuleController.js
// 选中的记录发生变化过后的事件
selectionChange : function(model, selected, eOpts) {
// 设置删除按钮的状态
this.getView().down(‘toolbar button#delete‘)[selected.length > 0
? ‘enable‘
: ‘disable‘]();
var viewModel = this.getView().getViewModel();
// 以下将组织选中的记录的name显示在title上,有二种方案可供选择。一种是用以下的MVVM特性。另外一种是调用refreshTitle()
var selectedNames = ‘‘
if (selected.length > 0) {
if (!!selected[0].getNameValue())
selectedNames = selectedNames + ‘ 『<em>‘ + selected[0].getNameValue()
+ ‘</em>‘
+ (selected.length > 1 ?
‘ 等‘ + selected.length + ‘条‘ : ‘‘) + ‘』‘;
}
viewModel.set(‘selectedNames‘, selectedNames); // 改动ModuleModel中的数据,改动好后会自己主动更新bind的title
// this.getView().down(‘grid‘).refreshTitle(); // 这是不用MVVM特性的做法
},
? ? ? ? 想下载源代码的能够到我的资源里去下载,或者点击打开链接进入下载页面。
?
跟我一起学extjs5(20--模块Grid的其它功能的设想,前20节源代码)
原文:https://www.cnblogs.com/mqxnongmin/p/10852198.html