I have implemented a RadListBox that utilizes the reorder and delete functionality provided by AllowReorder and AllowDelete. It worked fine until I also began to use the ItemTemplate functionality to create list items as hyperlinks (thanks to some fantastic help from Genady in this forum).
When the listbox first appears, everything is fine. The list items are hyperlinks. If I click off to the side of one of the list items (so the hyperlink is not fired, but the item is selected), and then click either the Move Up or the Move Down button, the item is moved up or down as it should be but, an additional item, with the same name, is added to the list and it is NOT a hyperlink. So, after the Move up or Move down action I have two instances of the selected item in the list. One is a hyperlink and one is not.
As a work-around, I have been experimenting with using the client-side API to handle the reorder and delete functionalty, per the examples on this site. But, that will open up another can of worms, and I would rather avoid doing that.
Has anyone else experienced problems with AllowReorder when using an ItemTemplate to customize the display?
Thanks for any advice you can give.
UPDATE: I used the onClientReordered event to trap the event in an attempt to remove the "additional", non-hyperlink item that was
"added" to the list. When I did this, both items were removed from the list. So, I think that an item wasn't actually added when the Move UP or Move Down buttons are used but, the single item is displaying regular text along with the hyperlink after it is moved in the list. I thought this might be helpful information.
13 Answers, 1 is accepted
I was unable to recreate this issue. I created a listbox, bound to a SqlDataSource, created an item template with a link, and turned on reorder/delete, and it functioned as expected. Do you think you could post a code snippet, or a small project demonstrating the issue? If it is easier i can get you my simple project, and have you recreate the issue using it.
Thank you,
Joshua Holt
Genady provided an example using a list box and itemtemplate in response to a thread I started here:
http://www.telerik.com/community/forums/aspnet-ajax/listbox/need-advice-on-implementing-an-editable-list.aspx
If you download the example (radlistboxtest.zip) Genady provided in the second post of that thread, and change the declaration of the radlistbox in Default2.aspx to include AllowReorder="true" and AllowDelete="true", then you will see the behavior I am describing.
The listbox loads perfectly but, if you select a list item and click one of the re-order buttons, the item is reordered appropriately but, its text is listed twice; once as regular text and once as a hyperlink (per the template).
The case I have in my actual project is slightly more complicated because I am creating the list box from within and xsl transformation but, the behavior is the same. If I can get it to work in this simplified example, I am sure I can get it to work from within the xslt.
Thanks very much for your help.
I have just download the example Genady provided, and changed the 2 properties as you explained. I was still not able to recreate the issue you are encountering. What version of the controls are you using?
Thank you,
Joshua Holt
Thanks again for you willingness to look into this.
I have tried to upload screen shots (png files, about 35k each) but can't seem to do that. I have tried doing it with IE and with Firefox.
Maybe I am just loosing my mind! ;-)
I have managed to reproduce the issue. It is really strange, it seems to appear only when the item template is being set from the codebehind. However, since the client side reorder does not involve postbacks I can hardly believe that this is the reason. We will research the problem and will write a follow up to you as soon as we find out what is going wrong.
Regards,
Genady Sergeev
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
We have found the problem. It was not bug in the listbox but in the way I was attaching the templates in the sample project. When template is applied from the codebehind, the items should also be applied from the codebehind. Moreover, the template should applied to the items in the Page_Init event, not in Page_Load. I have attached my modified sample as an attachment.
Kind regards,
Genady Sergeev
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
I give up.
I think I am going to try some other way of accomplishing this.
Thanks very much for your help.
it's interesting, that you can't recreate this issue.
After reordering (my template is inline) the reordered item occurs twice:
<span class="rlbTemplate"> |
<a id="lstLinks_i1_HyperLink1" href="%3Ca%20href=%22http://www.google.com%22%20target=%22_blank%22%3Ehttp://www.google.com%3C/a%3E" target="_blank"></a> |
<a href="http://www.google.com" target="_blank">http://www.google.com</a> |
</span> |
Thanks,
Andreas
This is bug of RadListBox's reorder functionality which we are aware of. I am happy to announce that the bug is already fixed. You can verify this on the Q1 Service Pack 1 which is going to be released by the end of the week.
Greetings,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thanks
The issue is going to be resolved for the upcoming Q2 release. The Q2 release is scheduled for the middle of July. Meanwhile you can use the following workaround, please paste the following code right after your ScriptManager delaration:
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<script type=
"text/javascript"
>
Telerik.Web.UI.RadListBoxItem.prototype._render =
function
(html) {
var
listBox =
this
.get_listBox();
this
._renderBeginTag(html);
if
(
this
.get_checkable() && listBox._checkBoxes)
this
._renderCheckBox(html);
if
(
this
.get_imageUrl())
this
._renderImageElement(html);
if
(
this
._parent && !
this
._parent._isTemplated)
this
._renderTextElement(html);
this
._renderEndTag(html);
}
</script>
<telerik:RadListBox runat=
"server"
ID=
"RadListBox1"
AllowReorder=
"true"
>
<Items>
<telerik:RadListBoxItem Text=
"Text1"
/>
<telerik:RadListBoxItem Text=
"Text2"
/>
<telerik:RadListBoxItem Text=
"Txet3"
/>
</Items>
<ItemTemplate>
<%
# DataBinder.Eval(Container, "Text") %>
</ItemTemplate>
</telerik:RadListBox>
Again, the issue is going to be resolved for the upcoming release.
Sincerely yours,
Genady Sergeev
the Telerik team
Thanks