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

Add "Print" option in CommandItemSettings

4 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Apoorv Gupta
Top achievements
Rank 1
Apoorv Gupta asked on 04 Nov 2009, 10:43 AM
I want to add "Print" option in CommandItemSettings along with existing Export Options. Is there a way I can extend CommandItemSettings, or do I need to create my own CommandItemTemplate?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Nov 2009, 11:29 AM
Hello Apoorv,

I would suggest you to make use of the CommandItemTemplate of the grid inorder to customize your command row. You can also add a control to the default command row as shown below:
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridCommandItem) 
        { 
            LinkButton lnkbtn = new LinkButton(); 
            lnkbtn.ID = "btnPrint"
            lnkbtn.Text = "  Print Grid"
            lnkbtn.CommandName = "Print"
            GridCommandItem cmdItem = (GridCommandItem)e.Item; 
            cmdItem.Controls[0].Controls[0].Controls[0].Controls[0].Controls.Add(lnkbtn); 
        } 
    } 

Thanks
Princy.
0
Apoorv Gupta
Top achievements
Rank 1
answered on 04 Nov 2009, 11:36 AM
Hi Princy,
Thanks for the response. I am evaluating the product for one of my client and this was my first post and I wasn't expecting such a fast response.

I was also inclining towards CommandItemTemplte option after going thru the documentation. Also the approach you mentioned for adding button dynamically would work but would be less maintainable.

Thanks
Apoorv
0
Pooya
Top achievements
Rank 1
answered on 26 Jul 2011, 03:10 PM
I have the same issue and the grid is inside an update panel and the new Command button has to trigger a postback rather than an async postback. how would that be possible?
0
Martin
Top achievements
Rank 1
answered on 07 Jan 2012, 12:05 AM
I want to do the same thing. Although I don't like it for maintainability it's probably the simplest solution for now. But I suggest that Telerik makes available the ability to export a CommandItemsSettings to a CommandTemplate. This would allow people to maintain the standard look and feel while easily adding in another button.

Reproducing a standard Command Bar isn't trivial.

Martin
Tags
Grid
Asked by
Apoorv Gupta
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Apoorv Gupta
Top achievements
Rank 1
Pooya
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Share this question
or