C# Radpanelbar 折叠/展开问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1180448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Radpanelbar collapse/expand issue
提问by Icemanind
Guys, I am having an issue with Telerik's RadPanelBar control. I have the Q1 2009 version of the controls. I have the follow ASP.NET code:
伙计们,我遇到了 Telerik 的 RadPanelBar 控件的问题。我有 2009 年第一季度的控件版本。我有以下 ASP.NET 代码:
<telerik:RadPanelBar Width="297px" ID="RadPanelBar1" runat="server" Skin="Web20" AllowCollapseAllItems="True" ExpandMode="SingleExpandedItem" PersistStateInCookie="True">
<Items>
<telerik:RadPanelItem runat="server" Text="Standard Reports" Expanded="True">
<ItemTemplate>
... Standard HTML Template code here ...
</ItemTemplate>
</telerik:RadPanelItem>
<telerik:RadPanelItem runat="server" Expanded="false" Text="NonStandard Reports">
<ItemTemplate>
<asp:Label runat="server" Text="test"></asp:Label>
</ItemTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>
Everything works fine, except I cannot expand or collapase the headers. My cursor changes to a hand when I hover over the headers, however nothing happens when I click on the header. Can someone help me out?
一切正常,除了我无法展开或折叠标题。当我将鼠标悬停在标题上时,我的光标会变成一只手,但是当我点击标题时没有任何反应。有人可以帮我吗?
Thanks
谢谢
采纳答案by Atanas Korchev
If you set the ItemTemplate of top level items - you will define the content of the item not the collapsible area. To solve the problem define a child item and set its ItemTemplate property instead:
如果您设置顶级项目的 ItemTemplate - 您将定义项目的内容而不是可折叠区域。要解决该问题,请定义一个子项并设置其 ItemTemplate 属性:
<telerik:RadPanelBar runat="server">
<Items>
<telerik:RadPanelItem Text="Standard Reports">
<Items>
<telerik:RadPanelItem>
<ItemTemplate>
... Standard HTML Template code here ...
</ItemTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>
I hope this helps!
我希望这有帮助!
回答by ajh1138
Do you have a telerik:RadScriptManager on the page?
您在页面上有 Telerik:RadScriptManager 吗?
回答by Maarten Louage
Did you try the above method when adding databound controls in the ItemTemplate? So for instance where you have written "... Standard HTML Template code here ..." to put:
在ItemTemplate中添加数据绑定控件的时候有没有试过上面的方法?因此,例如,您在此处编写了“...标准 HTML 模板代码...”以放置:
<ItemTemplate>
<asp:Label ID="lblText" runat="server" Text="The index has as ID "></asp:Label>
<asp:Label ID="lblIndexID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
</ItemTemplate>
My ItemTemplate is always empty. I'm binding to an ICollection. I can't figure out why this isn't working...
我的 ItemTemplate 始终为空。我绑定到 ICollection。我不明白为什么这不起作用......
回答by TiagoSC
You can use ContentTemplate:
您可以使用内容模板:
<telerik:RadPanelBar runat="server">
<Items>
<telerik:RadPanelItem Text="Standard Reports">
<ContentTemplate>
... Standard HTML Template code here ...
</ContentTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>