Grid列选中一行某些按钮启用
例:gridId(Grid ID)
btnEditId(编辑按钮ID)
btnDeleteId(删除按钮ID)
JS:
var setButtonStatus = function (gridId, btnEditId, btnDeleteId)
{
var gridView =
Ext.getCmp(gridId).getSelectionModel(); //获取Grid列选中状态
if
(gridView.hasSelection()) {
if (typeof
(Ext.getCmp(btnEditId)) !=
‘undefined‘) //判断控件状态
Ext.getCmp(btnEditId).setDisabled(false); //设置控件显示
if
(typeof (Ext.getCmp(btnDeleteId)) != ‘undefined‘)
Ext.getCmp(btnDeleteId).setDisabled(false);
}
else
{
if (typeof (Ext.getCmp(btnEditId)) != ‘undefined‘)
Ext.getCmp(btnEditId).setDisabled(true);
if
(typeof (Ext.getCmp(btnDeleteId)) != ‘undefined‘)
Ext.getCmp(btnDeleteId).setDisabled(true);
}
}
调用:
item.Add(Html.Y().Grid(Model.GridId, Model.StoreId)
.Listeners(l =>
{
l.SelectionChange.Handler +=
string.Format(@"setButtonStatus(‘{0}‘,‘{1}‘,‘{2}‘)"
, Model.GridId, vm.BTN_HBOOK_ITEM_EDIT,
vm.BTN_HBOOK_ITEM_DELETE);
})