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

item template in dynamic columns

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kshitiz
Top achievements
Rank 1
Kshitiz asked on 07 May 2012, 02:35 PM
I have a dynamic columns and dynamic rows which am binding in rad grid
ex:-


name col1 col 2 col3 col4  TOtal
a  -----1------4-----5-----7 --------- 45
b ------1------4-----5-----7  --------- 45 
c ------1------4-----5-----7  --------- 45 
tota--16-----64---65----67  ----------100


now i want to insert item template in all this values so that user can enter numeric fields .. also i want regular expressions
i dont have any name of columns since user can edit column names also ... also TOTAL 
please tell me how can i do this 

1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 09 May 2012, 10:23 PM
I would suggest that you reference the RadGrid documentation page which explains how to create template columns dynamically.

http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

This is covered in the last section entitled 'Creating template columns programmatically'.

You can get the name that the user assigns for the column and then use it to replace the hardcoded column name in the following snippet:

string templateColumnName = "ContactName";
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.ItemTemplate = new MyTemplate(templateColumnName);

Also, it's pretty easy to combine regular expression with a RadNumericTextBox that you add to your ItemTemplate to additionally validate user input while typing. You can reference this forum thread for insights.

Hope this helps!
Tags
Grid
Asked by
Kshitiz
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or