This is a migrated thread and some comments may be shown as answers.

Order of events: grid change vs. grid cell click

1 Answer 773 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 10 Jun 2020, 08:46 AM

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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetomir
Telerik team
answered on 15 Jun 2020, 05:37 AM

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.
Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or