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

CommandItemTemplate and mixed mode

2 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Francis
Top achievements
Rank 1
Francis asked on 30 Nov 2012, 01:30 PM
Hi,

in my application, I made a custom Grid control who inherit from RadGrid.

I want every grid to have the ExportToExcel command. But I also want, in some grid, add another "custom" command.

So I create a class who implement the ITemplate interface in my custom grid control, I use this template. It works good.

But now, in some grid, I want to add a custom DropDoxnList in the Grid Command Item Display area. So I add a <CommandItemTemplate> tag in my aspx. But as I can see, this tag is override by my template.

Is it possible to mix programatic and declarative mode ?


Thanks !

2 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 04 Dec 2012, 03:59 PM
Hi Francis,

I am afraid what you are trying to achieve is not possible. You should add it in your custom command item.

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Francis
Top achievements
Rank 1
answered on 05 Dec 2012, 06:53 AM

Hi,

finally, I found a sort of solution :

In my custom grid control, I add a property CustomControl :

public Control CustomControl { get; set; }

 

In my page, I dynamically create a div with my DropDownList inside (no need to paste the code here). And I set the CustomControl property with this div.

In my custom grid control, in the OnInit event, I set the MasterTableView.CommandItemTemplate property :

this.MasterTableView.CommandItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildCommandItemTemplate));

And in the BuildCommandItemTemplate delegate method, I add the ExportToExcel command and, if the property is not null, the CustomControl.

And It works !

The control created in the page (in my case, a DropDownList) can have events who are catched in the page.


Regards

Tags
Grid
Asked by
Francis
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Francis
Top achievements
Rank 1
Share this question
or