Order of events: grid change vs. grid cell click

2 posts, 1 answers
  1. Boris
    Boris avatar
    24 posts
    Member since:
    Aug 2015

    Posted 10 Jun 2020 Link to this post

    Hello,

    I have a grid with custom template column and with event handler for grid change event (I have omitted not important parts of code):

        @(Html.Kendo().Grid<OpportunityTool.Models.AccountForGrid>()
            .Name("AccountGrid")
            .Columns(columns =>
            {
                // other columns definitions - not important here
                columns.Bound(p => p.SlaveAccount.Owneridname).Title("Vlastník")
                    .ClientTemplate("<div class='contact-presenter'>#=SlaveAccount.Owneridname#</div>");
            })
            .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
            .Events(events => events
                                .Change("AccountGridChange"))
        )

    I have assigned event handler for click on my custom column too:

        $('#AccountGrid').on('click', '.contact-presenter', showContactDetail);

    I want to prevent the selection of the whole row, when user clicks on my custom column. I don't know how to do it, because change event is fired before cell click event.

    Is there a way to change the order of the events?

     

    Thanks for help,

    Boris.

  2. Answer
    Tsvetomir
    Admin
    Tsvetomir avatar
    797 posts

    Posted 15 Jun 2020 Link to this post

    Hi Jiri,

    It is correct that at the time the click event for the custom element is triggered, the row is already selected. What I can recommend is that you immediately deselect the row:

    $('#grid').on('click', '.contact-presenter', function(e){
            var row = $(e.target).closest("tr");
              $(row).removeClass("k-state-selected")
          });

    I hope this helps.

     

    Kind regards,
    Tsvetomir
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top