We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom contex menu with custom binding

Hi, I would like to have multilevel contex menu where I could bind the context menu items. Is that possible in SfDataGrid? I attached exmaple which I would like to be able to do.



3 Replies

SJ Sathiyathanam Jeyakumar Syncfusion Team March 15, 2023 07:49 AM UTC

Hi Patrycja Maria Karys,Top of Form

Absolutely! It is possible to add sub-menus with command binding in the RecordContextMenu of SfDataGrid. To assist you in getting started, we have provided some code snippets below that illustrate how this can be accomplished.

Xaml

<syncfusion:SfDataGrid x:Name="sfdatagrid"

                        AllowEditing="True"                              

                        AutoGenerateColumns="False"

                        ItemsSource="{Binding OrderDetails}"  >

 

    <syncfusion:SfDataGrid.RecordContextMenu>

        <ContextMenu>

            <MenuItem Header="Move to tradebook">

                <MenuItem Header="First" Command="{Binding DataGrid.DataContext.FirstCommand}" CommandParameter="{Binding Record.OrderID}"/>

                <MenuItem Header="Second" Command="{Binding DataGrid.DataContext.SecondCommand}" CommandParameter="{Binding .}"/>

                <MenuItem Header="Third" Command="{Binding DataGrid.DataContext.ThirdCommand}" CommandParameter="{Binding .}"/>

            </MenuItem>

        </ContextMenu>

    </syncfusion:SfDataGrid.RecordContextMenu>

And you can get the GridRecordContextMenuInfo in your command callback. Which contains the Record and DataGrid. Refer to the below screenshot and a sample.


Output :