Grid with Radio Buttons in a column

1 Answer 516 Views
Grid
Jason
Top achievements
Rank 1
Veteran
Jason asked on 26 Sep 2023, 09:45 PM | edited on 26 Sep 2023, 09:50 PM

I want to do a grid, where there is a single radio button in the column, indicating which of those rows is "selected" in the dataset for processing in the backend. So I'll have multiple rows, with their own data in it, and a radio button that when clicked will leave the radio buttons in the other rows unselected. All data needs to be pushed to the server in a submit/post form.

How would I go about doing this in a sane method? The backend is expecting an object including other data from the form including a List<MyObject> from that grid, where MyObject is similar to the following:
long Id; // database ID for this object
bool IsSelected; // whether the radio button was checked
double SomeNumberValue; // value I want to track
int Order; // displayed order

Ultimately the object the controller is receiving is similar to this:
long TicketId;
...
List<MyObject> Items; // data from my grid above
...
string OtherData;

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 29 Sep 2023, 10:21 AM

Hi Jason,

Thank you for the details provided.

In order to achieve the desired behavior, I would recommend using a Select column. The following demo represents the implementation and the resulting behavior. You can see the selected IDs in the console below the Grid:

The select change could be applied to a property of the Model is needed.

I hope this information helps.

Kind Regards,
Anton Mironov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.

Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Veteran
Answers by
Anton Mironov
Telerik team
Share this question
or