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

li elements losing attributes after transfering

8 Answers 82 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 30 Aug 2012, 04:51 PM
I'm using Telerik version 2012.1.411.40

I'm not using the transfer buttons to transfer the elements between the two lists, I have another function that calls the "transferToDestination" function of the listbox.(client side obviously)

When it's done transferring, all of the element attributes that I defined disappear. Is there something I'm missing?

8 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 03 Sep 2012, 09:51 AM
Hello Chris,

This was a known bug in RadListBox that has now been fixed. If you upgrade your telerik controls to the latest version, the problem will be resolved.
 
Kind regards,
Bozhidar
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.
0
Chris
Top achievements
Rank 1
answered on 19 Sep 2012, 08:35 PM
Which version was this an issue with and which was it solved in? Specifically was it 2012 Q2 SP1?

I'm having a bit of trouble finding out which version Id relates to which release. Is there a list?
0
Chris
Top achievements
Rank 1
answered on 20 Sep 2012, 02:59 PM
I actually just updated to version 2012.2.724.40 and the issue still persists.
0
Bozhidar
Telerik team
answered on 20 Sep 2012, 03:37 PM
Hello Chris,

The bug we're aware of is fixed in version 2012.2.724.40. Perhaps you are encountering a different problem. Could you send the code for your ListBoxes as well as the transferring logic code, so that we can investigate the issue locally.
 
Regards,
Bozhidar
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.
0
Chris
Top achievements
Rank 1
answered on 20 Sep 2012, 04:35 PM
A short version of the client side code. I'm really just grabbing the selected items and going through each one and telling them to transfer to the destination list. Should I be applying the attributes to the new item?

var items = listbox.get_selectedItems();
var item;
var attributes;
var vloc;
var vid;
    for (var i = 0; i < items.length; i++) {
        item = items[i];
        listbox.transferToDestination(item);
        attributes = item.get_attributes();
        vloc = attributes.getAttribute("vloc");
        attributes.removeAttribute("vloc");
        vid = item.get_element();
}
<telerik:RadListBox ID="RadListBox1" runat="server" EnableDragAndDrop="false" TransferMode="Move"
                            OnDropped="RadListBox_Dropped" DataValueField="UNIT_ID" TransferToID="RadListBox2"
                            DataTextField="DISPLAYAS" OnClientItemDoubleClicking="c_event" OnClientLoad="reformat" DataKeyField="UNIT_ID" >
                            </telerik:RadListBox>
 
<telerik:RadListBox ID="RadListBox2" runat="server" SelectionMode="Multiple" TransferMode="Move"
                             EnableDragAndDrop="false" OnDropped="RadListBox_Dropped" DataValueField="UNIT_ID" TransferToID="RadListBox1"
                             DataTextField="DISPLAYAS" OnClientItemDoubleClicking="c_event" OnClientLoad="reformat" DataKeyField="UNIT_ID">
                            </telerik:RadListBox>
Protected Sub RadListBox1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadListBoxItemEventArgs) Handles RadListBox1.ItemDataBound
            Dim dataSourceRow As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
            e.Item.Attributes("UNITNBR") = dataSourceRow("UNITNBR").ToString()
            e.Item.Attributes("UNITTYPE_CD") = dataSourceRow("UNITTYPE_CD").ToString()
            e.Item.Attributes("U_LENGTH") = dataSourceRow("U_LENGTH").ToString()
            e.Item.Attributes("U_TYPE") = dataSourceRow("U_TYPE").ToString()
            e.Item.Attributes("U_CATEGORY") = dataSourceRow("U_CATEGORY").ToString()
            e.Item.Attributes("HAZMAT_FLG") = dataSourceRow("HAZMAT_FLG").ToString()
            e.Item.Attributes("U_HAZMAT") = dataSourceRow("HAZMAT").ToString()
            e.Item.Attributes("U_TROUBLE") = dataSourceRow("TROUBLE_FLG").ToString()
            e.Item.Attributes("DECK") = ""
            e.Item.Attributes("AREA") = ""
            e.Item.Attributes("ROW_NM") = ""
            e.Item.Attributes("TIER") = ""
            e.Item.Attributes("vloc") = ""
        End Sub
0
Chris
Top achievements
Rank 1
answered on 20 Sep 2012, 06:23 PM
It seems to be simply missing the HTML. The attributes are all there in the javascript. The reason I'm looking for all this is because I want to "click" on all the items in the second list that have a specific value for a specific attribute. Right now I can't get a collection of items based on attribute from the current api. So my plan was to simply use jquery to select the li's with the correct attribute value and "click" each one.
0
Accepted
Bozhidar
Telerik team
answered on 21 Sep 2012, 08:57 AM
Hello Chris,

Thank you for the clarification.

You are correct, the element attributes are indeed not transferred, and I've logged this issue for fixing. To satisfy your requirements you can do one of the following things:

1. You can use the following function, that returns an array of listbox items based on the attribute key and value:
function findItemsByAttribute(list, attributeName, value)
{
    var result = [];
    var allItems = list._getAllItems();
    for (var i = 0; i < allItems.length; i++)
    {
        if (allItems[i].get_attributes().getAttribute(attributeName) == value)
            result.push(allItems[i]);
    }
    return result;
}

2. Manually go through all the attributes and add them to the item's element when you transfer it in your transferItem() function and the use the jQuery approach.
 
Greetings,
Bozhidar
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.
0
Chris
Top achievements
Rank 1
answered on 21 Sep 2012, 01:04 PM
Thanks for your help. And yea, I've already implemented a solution similar to what you've suggested.

If I may make a suggestion, it would be great if you could add some more functions that return collections or arrays from the listbox.
Tags
ListBox
Asked by
Chris
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Chris
Top achievements
Rank 1
Share this question
or