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

CommandItemTemplate

6 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 08 Dec 2010, 04:01 PM
Is there a way to change the visiblity of buttons within the CommandItemTemplate tag?  If so what does the code look like to access this property?

Please disregard this thread.  I figured it out. 



6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 08 Dec 2010, 05:22 PM
Hi Michael,

There are cases in which you may want to access the controls inside your CommandItemTemplate from the code-behind and dynamically change their preferences (in par with some particular restrictions/certain conditions). In the following help topic are the steps you can perform to reference controls inside the CommandItemTemplate programmatically:
http://www.telerik.com/help/aspnet-ajax/grdcommanditemtemplate.html

I hope this helps.

Best wishes,
Pavlina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Adam
Top achievements
Rank 1
answered on 26 Jul 2011, 10:05 PM
I need to do this, but unfortunately the link no longer works. Can you please direct me on how to update controls in the CommandItemTemplate?

Thanks,
Adam
0
Shinu
Top achievements
Rank 2
answered on 27 Jul 2011, 05:06 AM
Hello Adam,

Try the following code snippet to hide a LinkButton in CommandItemTemplate.
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
      {
            GridCommandItem commandItem = e.Item as GridCommandItem;
            LinkButton button = commandItem.FindControl("LinkButton1")as LinkButton;
            button.Visible=false;
      }
}
For further information you can check the following documentation.
Command Item Template.

Thanks,
Shinu.
0
Adam
Top achievements
Rank 1
answered on 27 Jul 2011, 07:18 PM
Okay, I can update the control and get it to look the way I want in the grid, but it doesn't export when I call the ExportToPDF function in the code behind. I get all the row information, but nothing in the CommandItemTemplate. Here are my ExportSettings.
<ExportSettings OpenInNewWindow="true" FileName="Schedule" HideStructureColumns="true" ExportOnlyData="false">
                    <Pdf PageHeight="8.5in" PageWidth="11in" PageBottomMargin=".5in" PageTopMargin=".5in" PageLeftMargin=".5in" PageRightMargin=".5in" DefaultFontFamily="Arial" />
                </ExportSettings>

0
Adam
Top achievements
Rank 1
answered on 28 Jul 2011, 06:35 PM
I think it was because I had a table in the CommandItemTemplate and didn't use <colgroup> for the columns. If I understand correctly, it won't export HTML perfectly.
0
Pavlina
Telerik team
answered on 29 Jul 2011, 04:56 PM
Hello Adam,

There are a few rules that should be followed when exporting HTML tables to PDF. For more information about them please refer to the Exporting HTML tables section in the help article below:
http://www.telerik.com/help/aspnet-ajax/grid-pdf-export.html

All the best,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Adam
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or