我的准备功能有问题。我正在尝试选择Delete button
以便能够禁用/启用它。这是选择第一个项目的代码(可以是下拉组)。我正在尝试选择该组中的第一个项目。
var prepareRecruiter = function (grid, toolbar, rowIndex, record) {
var dropdown = toolbar.items.get(0);
dropdown.setDisabled(true);
};
我尝试了toolbar.items.get(0).get(0);
和toolbar.items.items.get(0);
的多个变体而没有成功。
如何选择删除按钮,以便我可以将其禁用?
我的网格命令有以下代码:
<ext:CommandColumn runat="server" Width="35" Sortable="false" fixed="true" meta:resourcekey="CommandColumnResource2" ID="ctl2108">
<Commands>
<ext:GridCommand Icon="ApplicationForm">
<Menu EnableScrolling="false">
<Items>
<ext:MenuCommand Text="Delete" Icon="ApplicationFormDelete" CommandName="Delete" meta:resourcekey="DeleteCommandResource1" />
<ext:MenuCommand Text="Disable" Icon="ApplicationFormDisable" CommandName="Disable" />
<ext:MenuCommand Text="Enable" Icon="ApplicationFormEnable" CommandName="Enable" />
</Items>
</Menu>
</ext:GridCommand>
</Commands>
<PrepareToolbar Fn="prepareRecruiter" />
<Listeners>
<Command Fn="REDcommand" />
</Listeners>
</ext:CommandColumn>
谢谢!
答案 0 :(得分:0)
您应该使用“button.menu”来访问菜单项。
示例强>
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test", "test" },
new object[] { "test", "test" },
new object[] { "test", "test" }
};
}
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
<script>
var prepareToolbar = function (grid, toolbar, rowIndex, record) {
var btn = toolbar.items.get(0);
btn.menu.items.get(0).disable();
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test 1" DataIndex="test1" />
<ext:Column runat="server" Text="Test 2" DataIndex="test2" />
<ext:CommandColumn runat="server" Width="35">
<Commands>
<ext:GridCommand Icon="ApplicationForm">
<Menu>
<Items>
<ext:MenuCommand Text="Delete" CommandName="Delete" />
<ext:MenuCommand Text="Disable" CommandName="Disable" />
<ext:MenuCommand Text="Enable" CommandName="Enable" />
</Items>
</Menu>
</ext:GridCommand>
</Commands>
<PrepareToolbar Fn="prepareToolbar" />
</ext:CommandColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>