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

Hidding a column

4 Answers 225 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
tim
Top achievements
Rank 1
tim asked on 07 Mar 2011, 12:42 PM
I am currently using a column with a boolean value to determine whether to enable/disable certain buttons on the itemselected event client side. The problem I have is that  I do not want to display this column to the user but I can't set visible=false as then the javascript will fail. For a radgrid I can set Display=false, but that option does not seem to exist with a treeList?

<telerik:RadTreeList ID="radTreeList" runat="server" AutoGenerateColumns="false"
                AllowPaging="false" PageSize="5" DataKeyNames="ID" ParentDataKeyNames="ParentTemplateId"
                OnNeedDataSource="radTreeList_NeedDataSource" Skin="Web20">
                <ClientSettings AllowPostBackOnItemClick="false">
                    <Selecting AllowItemSelection="True" />
                    <ClientEvents OnItemSelected="itemSelected" />
                </ClientSettings>
                <Columns>
                    <telerik:TreeListBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" />
                    <telerik:TreeListBoundColumn DataField="ModifiedTime" HeaderText="ModifiedTime" UniqueName="ModifiedTime" />
                    <telerik:TreeListCheckBoxColumn UniqueName="chkHasChildren" DataField="HasChildren"
                        HeaderText="HasChildren" />
                </Columns>
            </telerik:RadTreeList>

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 07 Mar 2011, 01:11 PM
Hi tim,

RadTreeList does not currently support hiding columns on the client. You will have to use a different approach for determining your boolean value. You can attach it as an attribute to an HTML element from the server, or add a hidden label to any of your other columns containing your boolean value which you can access on the client.

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
tim
Top achievements
Rank 1
answered on 08 Mar 2011, 11:17 AM
Hi Veli,

Would you be able to provide a quick example of how to a hidden label to one of the other columns?

Thanks
0
Accepted
Veli
Telerik team
answered on 08 Mar 2011, 01:55 PM
Yes, you can use a TreeListTemplateColumn like follows:

<telerik:TreeListTemplateColumn DataField="Name"
    HeaderText="Name" UniqueName="NameTemplate">
    <ItemTemplate>
        <%# Eval("Name") %>
        <asp:Label ID="HiddenLabel" runat="server"
            style="display:none">
            <%# Eval("Available") %>
        </asp:Label>
    </ItemTemplate>
</telerik:TreeListTemplateColumn>

The column binds to a specified data field (Name in this case) through a binding expression. When rendered, it looks like a regular bound column with text in a cell. However, the cell also contains a hidden label. This label's content is bound to another field (in my case - the boolean Available field). Now each hidden label in each tree list item contains either "True" or "False" as text. On the client, we can retrieve this value, for example in RadTreeList's client-side OnItemClick event:

<ClientSettings>
    <Selecting AllowItemSelection="true" />
    <ClientEvents OnItemClick="treeListItemClick" />
</ClientSettings>

function treeListItemClick(sender, args)
{
    var row = args.get_item().get_element();
    var hiddenLabel = $telerik.findElement(row, "HiddenLabel");
    alert(hiddenLabel.innerHTML);
}

Using $telerik.findElement() I find the hidden label by its server ID and retrieve its innerHTML. The label is not visible, but I get the data I have bound it to.

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
tim
Top achievements
Rank 1
answered on 08 Mar 2011, 02:42 PM
Thanks Veli.
Tags
TreeList
Asked by
tim
Top achievements
Rank 1
Answers by
Veli
Telerik team
tim
Top achievements
Rank 1
Share this question
or