OnClientTransferred not called

2 posts, 0 answers
  1. Nick
    Nick avatar
    7 posts
    Member since:
    Sep 2010

    Posted 15 Sep 2010 Link to this post

  2. ASP.NET 4.0
  3. Windows 7 x64
  4. IE 8
  5. ASP.NET AJAX RadListBox
  6. preferred programming language C#

  7. Hello,

    In my code I am attempting to keep the formatting between two RadListBoxes. To do this, I have a Javascript function that copies the innerHTML of the source item to the destination item. This function should be called once the item is transferred, however I have only observed it being called on the first transfer with only one item selected; any other time the function is not called. Why is this and how can I call the function consistently?

    Javascript functions:
    function CheckDuplicate(sender, e) {
        var source = e.get_sourceListBox();
        var dest = e.get_destinationListBox();
        var newItems = e.get_items();
        var oldItems = dest.get_items();
        if (oldItems.get_count() > 0)
            e.set_cancel(true);
        else
            return;
                 
        for (var i = 0; i < newItems.length; i++)
            for (var j = 0; j < oldItems.get_count(); j++) {
                if (newItems[i].get_value() == oldItems.getItem(j).get_value() ||
                        !newItems[i].get_isEnabled())
                    break;
                if (j == (oldItems.get_count() - 1))
                    sender.transferItem(newItems[i], source, dest);
             }
    }
     
    function Format(sender, e) {
        var dest = e.get_destinationListBox();
        var newItems = e.get_items();
        var oldItems = dest.get_items();
        for (var i = 0; i < newItems.length; i++)
            for (var j = 0; j < oldItems.get_count(); j++) {
                if (newItems[i].get_value() == oldItems.getItem(j).get_value())
                    oldItems.getItem(j).get_textElement().innerHTML =
                             newItems[i].get_textElement().innerHTML;
            }
    }

    ASPX
    <td>
    <telerik:RadListBox ID="RadListBoxGroup" runat="server" Height="200px"
          Width="300px" SelectionMode="Multiple" AllowDelete="True">
    </telerik:RadListBox>
    </td>
    <td class="frmLabel" style="vertical-align:text-top;">Employees:</td>
    <td>
    <telerik:RadListBox ID="RadListBoxEmployees" runat="server"
          DataValueField="UserName" Height="200px" Width="350px" AllowTransfer="true"
          onitemdatabound="RadListBoxEmployees_ItemDataBound"
          EnableDragAndDrop="true" TransferToID="RadListBoxGroup" 
          OnClientTransferring="CheckDuplicate" SelectionMode="Multiple"
          AllowTransferOnDoubleClick="True" TransferMode="Copy"
          OnClientTransferred="Format">
          <ButtonSettings Position="Left" />
          <ItemTemplate>
                <span id="name" runat="server" style="position:relative;float:left;">
                      <%# DataBinder.Eval(Container.DataItem, "LastName") %>,
                      <%# DataBinder.Eval(Container.DataItem, "FirstName") %>
                </span>
                <span id="position" runat="server"
                      style="position:relative;float:right;">
                      <%# extraHelp(DataBinder.Eval(Container.DataItem,
                             "itemNo").ToString()) %>
                      [<%# DataBinder.Eval(Container.DataItem, "itemDescAbbr") %>]
                </span>
           </ItemTemplate>
    </telerik:RadListBox>
    </td>

  • Nick
    Nick avatar
    7 posts
    Member since:
    Sep 2010

    Posted 16 Sep 2010 Link to this post

    Apparently the problem was 

    oldItems.getItem(j).get_textElement().innerHTML = newItems[i].get_textElement().innerHTML;

    It should be

    oldItems.getItem(j).get_element().innerHTML = newItems[i].get_element().innerHTML;

    The first one causes an error of which I was not being notified.
  • UI for ASP.NET Ajax is Ready for VS 2017
    Back to Top