ContextMenu on TreeList after first display shows menu regardless of click location

0 Answers 42 Views
Menu TreeList
Eric
Top achievements
Rank 1
Eric asked on 23 Sep 2021, 08:44 PM

I have a TreeList and a connected ContextMenu.   The context menu shows correctly the first time only when clicking on a TreeList row.  After that however, no matter where I right-click on the page, the context menu is displayed.


@(Html.Kendo().ContextMenu()
    .Name("orgtreemenu")
    .Target("#OrganizationTreeMaintenance")
    .Orientation(ContextMenuOrientation.Vertical)
    .Filter(".k-grid-content table tbody tr[role='row']")
    .Events(e => e
        .Open("orgContextMenuOpen")
        .Select("orgTreemenuSelect")
    )
    .Items(items =>
    {
        items.Add()
            .Text("Add Organization")
            .HtmlAttributes(new { @id = "addorgaction" })
            .Enabled(true);
        items.Add()
            .Text("Edit Name")
            .HtmlAttributes(new { @id = "editorgnameaction" })
            .Enabled(true);
        items.Add()
            .Text("Delete Organization")
            .HtmlAttributes(new { @id = "deleteorgaction" })
            .Enabled(true);

        items.Add()
            .Text("Move Organization")
            .HtmlAttributes(new { @id = "moveorgaction" })
            .Enabled(false);
    }))
@(Html.Kendo().TreeList<UserStatViewModel>()
    .Name("OrganizationTreeMaintenance")
    .Columns(columns =>
    {
        columns.Add().Field(e => e.OrganizationName).Width(300);
        columns.Add().Field(e => e.OrganizationId).Hidden(true);
        columns.Add().Field(e => e.TotalUserCount).Title("Users");
        columns.Add().Field(e => e.TotalDeviceCount).Title("Devices");
        columns.Add().Field(e => e.LicensedUserCount).Title("Licenses");
    })
    .Sortable()
    .HtmlAttributes(new { style = "height:500px;" })
    .Events(e => e
        .DataBound("onDataBoundLicenseTree"))
    .DataSource(dataSource => dataSource
        .Read(read => read.Action("GetOrgLicenseDetails", "home"))
        .ServerOperation(false)
        .Model(m =>
        {
            m.Id(f => f.OrganizationId);
            m.ParentId(f => f.ParentOrgId).DefaultValue(0);
            //           m.Expanded(true);
            m.Field(f => f.OrganizationName);
            m.Field(f => f.TotalDeviceCount);
            m.Field(f => f.ParentOrgId);
        })
    ))

I have tried modifying the Filter on the context menu to no avail.  Hoping someone can see something obvious.

Thanks and regards,

Eric Katz

Eric
Top achievements
Rank 1
commented on 24 Sep 2021, 01:37 PM | edited

Ok, this turned out to be user error.  There was a line of code in the open handler that was creating a duplicate context menu instead of just using 
e.sender

No answers yet. Maybe you can help?

Tags
Menu TreeList
Asked by
Eric
Top achievements
Rank 1
Share this question
or