Ticket T201476
Visible to All Users

Show / Hide Context menu items in dxgrid per row

created 10 years ago

Hi,

I'm using dxg:GridControl for my WPF application, which is binding the bank details which status will be active or deleted, for active banks, I would like to have Edit and Delete action when I right click the row, but for deleted banks, I only would like to have Edit action, may I know if there is any approach to only show Edit for those deleted banks. Thanks a lot!

C#
<dxg:GridControl ItemsSource="{Binding BankSource"> <dxg:GridControl.View> <dxg:TableView AutoWidth="True" AllowPerPixelScrolling="True" ShowGroupPanel="False" AllowFilterEditor="False" ShowGroupedColumns="True" BestFitMode="Smart" BestFitArea="All" ShowHorizontalLines="False" AllowEditing="False" NavigationStyle="Row" AllowHorizontalScrollingVirtualization="False" FadeSelectionOnLostFocus="False" ShowIndicator="False" FocusedRow="{Binding Path=SelectedBank, Mode=TwoWay}"> </dxg:TableView> </dxg:GridControl.View> <dxg:GridControl.ContextMenu> <ContextMenu> <MenuItem Name="mnuEdit" Header="Edit ..." Command="{Binding UpdateBankCommand}" CommandParameter="{Binding SelectedBank}"/> <Separator/> <MenuItem Name="mnuDelete" Header="Delete" Command="{Binding DeleteBankCommand}" CommandParameter="{Binding SelectedBank}"/> </ContextMenu> </dxg:GridControl.ContextMenu> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="name" Header="Bank Name" Width="80" /> <dxg:GridColumn FieldName="acctNum" Header="Card Number" Width="250" /> <dxg:GridColumn FieldName="acctName" Header="Holder Name" Width="90" /> <dxg:GridColumn FieldName="StatusDesc" Header="Status" Width="70" /> </dxg:GridControl.Columns> </dxg:GridControl>

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello,

We suggest using the TableView.RowCellMenuCustomization property to create a context menu for GridControl rows. You can read more here: Context Menus.

With this approach you can bind the BarButtonItem.IsVisible property to a property of an object in the row. I have created a simple example to show this approach. Try it and let me know your results.

Thanks,
Andrey

    Show previous comments (5)
    DevExpress Support Team 8 years ago

      You are welcome, Bosko.
      Should you need further assistance, feel free to contact us.

        Using the RowCellMenuCustomization and the DataTrigger with Row.DataContext.Property worked for me. Would be nice if a "Visibility" property was available instead of having to jump through this hoop :)

        DevExpress Support Team 3 years ago

          Hello,

          I created a separate ticket on your behalf: T1040947: It would be nice if a "Visibility" property was available for the RowCellMenuCustomizations items. We placed it in our processing queue and will process it shortly.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.