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

RadCombobox Item Template From Code Behind

1 Answer 360 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Swanand
Top achievements
Rank 1
Veteran
Swanand asked on 09 Sep 2020, 02:13 PM

Hi,

I am currently working on a problem where I have to add a radComboBox in editItemTemplate.

Background: The radGrid I am using is being added from the codebehind. All the columns are being added from the code behind too and are based on a local DataTable. The Grid is in BatchEditMode and has a RadAjaxManager used with it. It saves the change to the table as soon as the change is made. It is handled by calling SaveChanges function from javascript of cell value changed.

Problem: I need to add an ItemTemplate column to radGrid for a column in DataTable which has multiple values in it. Lets call this column as Tags. The values stored in it are either {Tag1}, {Tag2}, {} or {Tag1, Tag2}. It shows that multiple values(or no values) can be associated with one record. I need to be able to select these items or unselect them and then trigger the cell value changed function or any other function in the codebehind.

 

Can someone help me with a demo for this problem please? I am open for changing it to some other control if RadComboBox is not a good item to be used here.

Thanks in advance,

Swanand Nalawade

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 14 Sep 2020, 01:39 PM

Hi Swanand,

Since the RadGrid is created programmatically in the code-behind, you will need to create the template also dynamically. Therefore you must define a custom class that implements the ITemplate interface. Then you can assign an instance of this class to the ItemTemplate, check out the Creating Template Columns Programmatically section.

However, when it comes to using Templates, I would recommend using the InPlace edit mode or any other editing performed on the server-side.

I would suggest you check out the specifics in using Batch edit mode and when it is suitable for use in the RadGrid Batch Editing Templates and Specifics.

In case you want to keep using the Batch editing, you will need to manually handle the batch editing events, see Working With Templates.
Here is a forum post about a related topic including a sample that you may find useful to check out - https://www.telerik.com/forums/radgrid-edititemtemplate-radcombobox-selected-items-are-empty-in-radgrid-batchedit-event#0OPDe1oQt0axG7_pkXX_xA 

Kind regards,
Doncho
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Swanand
Top achievements
Rank 1
Veteran
Answers by
Doncho
Telerik team
Share this question
or