As mentioned in a previous thread, am using the solution in this thread to hide/ unhide columns.
In my scenario, out of the 10 columns in the grid am displaying 6 when am first loading the page. Am using checkboxes to hide/unhide each column.
Am facing a problem displaying the columns that are hidden on pageload. Am able to hide/unhide the 6 columns that are displayed on page load. Am guessing this might be due to the viewstate too.
Any suggestions to fix this would be helpful.
Thank you.
7 Answers, 1 is accepted

Give a try with the following code snippet to show the column which is hide initially.
ASPX:
<
telerik:GridBoundColumn
DataField
=
"FirstName"
HeaderText
=
"FirstName"
UniqueName
=
"FirstName"
Display
=
"false"
>
</
telerik:GridBoundColumn
>
Java Script:
<script type=
"text/javascript"
>
function
showColumn() {
var
radGrid = $find(
'<%= RadGrid1.ClientID %>'
);
var
table = radGrid.get_masterTableView();
var
columns = table.get_columns();
for
(idx = 0; idx < columns.length; idx++) {
var
column = columns[idx];
if
(column.get_uniqueName() ==
"FirstName"
) {
table.showColumn(idx);
}
}
}
</script>
-Shinu.

Thank you for the reply.
I tried out the code snippet you provided. It still does not work.
I placed an alert with columns.length and it returned the number of visible columns instead of total number of columns.
Is there any other function that would return all the columns(including the hidden ones?)
Thanks again!

The above code(columns.length) will return total number of columns if you are using 'Display="false" property to hide the column. Check whether you have used Visible property to hide the column. If so use Display property and see if it works. Hope this information helps.
ASPX:
<
telerik:GridBoundColumn
DataField
=
"FirstName"
UniqueName
=
"FirstName"
Display
=
"false"
>
</
telerik:GridBoundColumn
>
-Shinu.


Is there any way to hide a column for a specific row?
What I am ultimately trying to do is hide a control until a button in another column in the same row is clicked.
Referring to my code below I want to show the LinkButton 'LinkButtonSelectPerson' when the other LinkButton 'LinkButtonViewPerson' is clicked.
Thanks,
David
function DoIt(pid) {
var grid = $find("<%=GridClientSearchResults.ClientID %>");
var MyControl = $telerik.findControl(grid, "LinkButtonSelectPerson");
MyControl.style.display = 'block';
}
<telerik:RadGrid ID="GridClientSearchResults" runat="server" LocalizationPath="~/App_LocalResources"
EnableLinqExpressions="false" AllowPaging="true" AutoGenerateColumns="False"
GridLines="None" MasterTableView-DataKeyNames="PartyID" OnPageIndexChanged="GridClientSearchResults_PageIndexChanged"
OnItemCommand="GridClientSearchResults_ItemCommand" Skin="Windows7" PageSize="<%$appSettings:GridPageSize %>"
OnItemDataBound="GridClientSearchResults_ItemDataBound">
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonSelectPerson" Text="<%$ Resources:KEY_BTN_SELECT %>" Visible="false"
runat="server" ></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonViewPerson" OnClientClick="DoIt('<%# DataBinder.Eval(Container.DataItem,"PartyID")%>')" Text="<%$ Resources:KEY_BTN_VIEW_CLIENT %>" runat="server" CommandName="View" ></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="PartyID" DataField="PartyID" HeaderText="" Visible="false">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
I would suggest that you modify your code as below:
<
asp:LinkButton
ID
=
"LinkButtonViewPerson"
OnClientClick
=
"DoIt(this, '<%# DataBinder.Eval(Container.DataItem,"
PartyID")%>')" Text="<%$ Resources:KEY_BTN_VIEW_CLIENT %>" runat="server" CommandName="View" ></
asp:LinkButton
>
function
DoIt(sender, pid) {
var
LinkButtonViewPerson = sender;
var
MyControl = $find(sender.id.replace(
"LinkButtonViewPerson"
,
"LinkButtonSelectPerson"
));
MyControl.style.display =
'block'
;
}
Let me know if it works for you.
Kind regards,
Iana
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.

It turns out the $find method returned null so I changed $find to $get and that was all I had to modify.
Thanks again,
David