Find OnRowClicked Event In Razor Page

1 Answer 93 Views
Grid
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
Mohamad Javad asked on 12 Dec 2022, 02:23 PM

Hi

I Need Find Event Row click  server side In asp.net core 6 ,  Razor page.

my code is :

                    @(Html.Kendo().Grid<MSG_UserTicketsList_ForFolderModel>
                        ().Name("grid")
                        .Scrollable()
                        .Selectable(selectable => selectable
                        .Mode(GridSelectionMode.Single)
                        .Type(GridSelectionType.Row))
                        .Events(events => events.Change("onChange"))
                        .Columns(columns =>
                        {
                            columns.Bound(e => e.TicketId).Title(" ").ClientTemplate(
                                "# if ( DoerTicketStatus    == 'False') { #" +
                            "<div class='UnreaedTicket'>" +
                            "# } else { #" +
                            "<div>" +
                            "# } #" +
                            "<div class='main-mail-item' >" +
                            "<div class='main-mail-star'>" +
                            "<i class='typcn typcn-star'></i>" +
                            "</div>" +
                            "<div class='main-img-user'>" +
                            "<img src='" + Url.Content("~/UserImage/") + "#:data.TicketCreatorId#.png' />" +
                            "</div>" +
                            " <div class='main-mail-body'>" +
                            " <div class='main-mail-from'>" +
                            "Ticket#: TicketId # &nbsp; &nbsp; #: MyName # (#: UserName #) " +
                            "</div>" +
                            "<div class='main-mail-subject'>" +
                            "<strong>#: Subject #</strong>" +
                        @*      "<div class='row'>&nbsp; #: Subject # &nbsp;</div>"+*@
                        "</div>" +
                        "</div>" +
                        "<div class='main-mail-date'>" +
                        "#: LastUpdateDate #" +
                        "</div>" +
                        "</div>" +
                            "</div>"
                                );
                        })
thanks

 

Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
commented on 15 Dec 2022, 09:46 AM

Can anyone answer me?

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 20 Dec 2022, 04:13 AM

Hi Mohamad Javad,

Thank you for sharing a code snippet.

As far as I understand the requirement at hand, you are looking to throw a click event when a row of the Grid is being clicked. As such an event is not exposed out-of-the-box you would need to use JavaScript to subscribe to the click and handle it:

  1. Define a custom attachRowClickHandler function
    function attachRowClickHandler(){
           $("tr[role='row']").off().on("click", yourClickHandlerHere);
    }
  2. Handle the Grid's DataBound Event to ensure the rows are already added to the Grid and call the attachRowClickHandler there
    .Events(e=>e.DataBound("onDataBound"))
    function onDataBound(e){
           attachRowClickHandler();
    }

I hope the approach above is useful.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Mohamad Javad
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stoyan
Telerik team
Share this question
or