2014-11-05 70 views
0

我遇到了我的準備功能問題。我試圖選擇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);沒有成功行多種變型。

如何選擇刪除按鈕,以便我可以禁用它?

enter image description here

我有以下代碼爲我gridcommand:

<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

您應該使用「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> 
+0

邏輯上使得有很大的意義。從那以後,我改變了構建頁面的方式,所以我無法測試這個答案,但我會在未來的項目中記住它。 – starvator 2014-11-14 12:49:01