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

visible=false, no item index?

3 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phillip
Top achievements
Rank 1
Phillip asked on 29 Nov 2011, 10:25 PM
I'm trying to hide a bunch of columns and display a bunch of columns when clicking print.  However, it appears that if the item is visible = false then it does not have an index and therefore I can't use showcolumn.  Anyone know a way around this? 

MasterTable.showColumn("0");
<Columns>
    <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" 
        UniqueName="PrintColumn" Visible="False" >
        <ItemTemplate>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Nov 2011, 06:43 AM
Hello,

 You can access the invisible column by its ColumnUniqueName.Try the following code snippet to show the invisible column on button click.
CS:
protected void Button1_Click(object sender, EventArgs e)
{
  foreach (GridColumn col in grid1.MasterTableView.Columns)
  {
    if (col.UniqueName == "FirstName")
     {
       col.Visible = true;
     }
  }
 grid1.Rebind();  
}

Thanks,
Princy.
0
Phillip
Top achievements
Rank 1
answered on 01 Dec 2011, 06:40 PM
Princy,

Thanks for the reply, but I'm trying to this with javascript on button click.  Thanks
0
Antonio Stoilkov
Telerik team
answered on 06 Dec 2011, 04:55 PM
Hello Phillip,

You could achieve your scenario by following the steps below:
  • Instead of Visible="false" use Display="false" for the grid column, this way the column will be rendered and could be accessed client-side.
  • Call the MasterTableView showColumn method with the appropriate column index.

Regards,
Antonio Stoilkov
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
Tags
Grid
Asked by
Phillip
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Phillip
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or