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

[Solved] CommandItemTemplate

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
OmahaDue
Top achievements
Rank 1
OmahaDue asked on 22 Feb 2010, 04:00 PM
How can you create two separate CommandItemTemplate on the grid, so that one can be on the top while the other at the bottom and they are function differently? For example, one use to clear all filters and the other one use to export to excel etc.

Thanks for the help.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 22 Feb 2010, 05:19 PM
Hello,

RadGrid doesn't support this functionality out-of-the-box, but you could try to implement it on your own.

Sample code:
class MyTemplate : ITemplate
{
    public void InstantiateIn(Control container)
    {
        LiteralControl litCtrl = new LiteralControl();
        litCtrl.ID = container.ClientID + "litCtl";
        if (isTop(container))
            litCtrl.Text = "TOP";
        else
            litCtrl.Text = "BOTTOM";
        container.Controls.Add(litCtrl);
    }
 
    protected bool isTop(Control container)
    {
        GridCommandItem item = container.NamingContainer as GridCommandItem;
        return item.OwnerTableView.GetItems(GridItemType.CommandItem)[0] == item;
    }
 
    public MyTemplate()
    { }
}

Please mind that this approach is not guaranteed to work in all scenarios.

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
OmahaDue
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or