li elements losing attributes after transfering

9 posts, 1 answers
  1. Chris
    Chris avatar
    12 posts
    Member since:
    Aug 2012

    Posted 30 Aug 2012 Link to this post

    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?
  2. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 03 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    12 posts
    Member since:
    Aug 2012

    Posted 19 Sep 2012 Link to this post

    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?
  5. Chris
    Chris avatar
    12 posts
    Member since:
    Aug 2012

    Posted 20 Sep 2012 Link to this post

    I actually just updated to version 2012.2.724.40 and the issue still persists.
  6. Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 20 Sep 2012 Link to this post

    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.
  7. Chris
    Chris avatar
    12 posts
    Member since:
    Aug 2012

    Posted 20 Sep 2012 Link to this post

    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
  8. Chris
    Chris avatar
    12 posts
    Member since:
    Aug 2012

    Posted 20 Sep 2012 Link to this post

    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.
  9. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1103 posts

    Posted 21 Sep 2012 Link to this post

    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.
  10. Chris
    Chris avatar
    12 posts
    Member since:
    Aug 2012

    Posted 21 Sep 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017