Postback on row selection in rad grid

1 Answer 185 Views
Ajax Grid Navigation UI for ASP.NET AJAX in ASP.NET MVC
Sonia
Top achievements
Rank 1
Sonia asked on 15 Dec 2021, 05:59 PM

I am dealing with a scenario where in grid , whether user clicks on a row or uses up/down arrow in the grid to select a row, it should do a postback and update other fields on the page. During research I have found that EnablePostBackOnRowClick and AllowKeyboard Navigation cannot work at the same time. This is what I have :

<Selecting AllowRowSelect="true" />

 <ClientEvents OnRowSelected="GridRowSelected" OnRowMouseOver="RowMouseOver" />

 

  function GridRowSelected(sender, args) {

// do a post back to update other controls on the  page

}

 

Can someone please help me in achieving this? I have tried different methods explained in forum but nothing worked for me. In short, I want it to do a post back  when either user clicks on a row or make a selection using keyboard navigation and call this:

  void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)

{

}

 

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 20 Dec 2021, 02:19 PM

Hi Sonia,

Since a postback is needed after each selection I would suggest you use the Server-side selection instead of the client-side one. Check out our Row Selection demo and also the Server-side Selecting with a CheckBox article explaining how you can achieve an appearance similar to the one with the ClientSelect column.

As to the keyboard selection, RadGrid exposes the KeyPress event which you can use to execute custom logic. For instance, you can handle the keyPress and trigger the programmatic selection of the currently active Grid Row when the Space key is pressed.

I have attached a sample demonstrating the suggested approach. Add the Telerik.Web.UI.dll in the bin folder to be able to run the project.

I hope this will help you achieve the desired.

Kind regards,
Doncho
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
Ajax Grid Navigation UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Sonia
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Share this question
or