set_imageurl not working after transferring item

3 posts, 1 answers
  1. Christian
    Christian avatar
    13 posts
    Member since:
    May 2009

    Posted 19 Apr 2013 Link to this post

    Hi,

    I can change the ImageUrl after transferring an item from left to right.
    BUT if I transfer it to left and then to the right side again. The ImageUrl cannot be change.

    Here's the demo:

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="Test.WebForm1" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
     
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            var containerPrefix = '';
            var trvElementsID = containerPrefix + 'trvElements';
            var trvQueriesID = containerPrefix + 'trvQueries';
            var trvOrdersID = containerPrefix + 'trvOrders';
            var trvRangesID = containerPrefix + 'trvRanges';
            var lsbOrderItemTargetID = containerPrefix + 'lsbOrderItemTarget';
            var hidQueriesChangedID = containerPrefix + 'hidQueriesChanged';
            var hidOrdersChangedID = containerPrefix + 'hidOrdersChanged';
            var hidRangesChangedID = containerPrefix + 'hidRangesChanged';
             
            function ToggleSort(sender, args) {
                //    debugger;
                var imgAsc = 'ascending.png';
                var imgDesc = 'descending.png';
                var listboxTarget = $find(lsbOrderItemTargetID);
     
                if (listboxTarget) {
                    var selectedItem = listboxTarget.get_selectedItem();
     
                    if (selectedItem) {
                        listboxTarget.trackChanges();
                        //imageUrl
                        var oldImgUrl = selectedItem.get_imageUrl();
                        var arrUrl = oldImgUrl.split("/");
     
                        //value
                        var oldValue = selectedItem.get_value();
                        var arrValue = oldValue.split(".");
     
                        if (arrValue[0] == 'asc') {
                            arrValue[0] = 'desc';
                            arrUrl[arrUrl.length - 1] = imgDesc;
                        } else {
                            arrValue[0] = 'asc';
                            arrUrl[arrUrl.length - 1] = imgAsc;
                        }
     
                        var newImgUrl = arrUrl.join("/");
                        var newValue = arrValue.join(".");
                         
                        selectedItem.set_value(newValue);
                        selectedItem.set_imageUrl(newImgUrl);
                        listboxTarget.commitChanges();
                    }
                    else {
                        alert('no item selected');
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" ScriptMode="Release" EnableScriptLocalization="true" EnableScriptGlobalization="true"
            CombineScripts="false" runat="server" EnablePartialRendering="true" />
     
            <div>
            <telerik:RadListBox ID="lsbOrderItemSource" SelectionMode="Multiple" AllowTransfer="true" AllowReorder="false" TransferToID="lsbOrderItemTarget"
                PersistClientChanges="true" Skin="Outlook" runat="server" Height="500px" Width="30%" >
                    <Items>
                        <telerik:RadListBoxItem Text="test1" ImageUrl="Images/ascending.png"/>
                        <telerik:RadListBoxItem Text="test2" ImageUrl="Images/ascending.png"/>
                        <telerik:RadListBoxItem Text="test3" ImageUrl="Images/ascending.png"/>
                        <telerik:RadListBoxItem Text="test4" ImageUrl="Images/ascending.png"/>
                    </Items>
                </telerik:RadListBox>
     
            <telerik:RadButton runat="server" ID="teleriktoggle" Text="ASC/DESC" OnClientClicked="ToggleSort" AutoPostBack="false"></telerik:RadButton>
            <telerik:RadListBox ID="lsbOrderItemTarget" SelectionMode="Multiple"
                AllowReorder="true" Skin="Outlook" runat="server" Height="500px" Width="30%" PersistClientChanges="true"/>
            </div>
        </div>
        </form>
    </body>
    </html>


    Thanks in advance for your help.
    Christian.
  2. Christian
    Christian avatar
    13 posts
    Member since:
    May 2009

    Posted 24 Apr 2013 Link to this post

    Anybody?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 24 Apr 2013 Link to this post

    Hello Christian,

    This is a development issue, which I have logged. As a temporary workaround, I could suggest you to enable the AutoPostBackOnTransfer property of the Source RadListBox. If you do not want a postback to occur when transferring items, you could still use the aforementioned property, but in addition you could ajaxify the RadListBoxes. As a token of gratitude, for reporting for that problem, I have updated your Telerik Points.

    Greetings,
    Nencho
    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.
Back to Top