Issue With Transferring Items

7 posts, 1 answers
  1. Mike
    Mike avatar
    74 posts
    Member since:
    Mar 2013

    Posted 13 Mar 2015 Link to this post

    I have a page that has a list of available companies on the left and the list of selected companies on the right.  I can successfully transfer (move) items from left to right, but not right to left.  I have done the same functionality in a different project and it works just fine.  I event copied that code into this project and it doesn't transfer right to left.  My original code is running under Telerik version 2014.1.403.40.  This code is using  2015.1.225.45.
    Markup:
    <tr>
        <td>
            <telerik:RadListBox runat="server" ID="radCompany" Sort="Ascending" AllowTransfer="True" TransferToID="radSelectedCompanies" Width="300px"
                Height="200px" AutoPostBackOnTransfer="True" AllowTransferOnDoubleClick="True" EnableDragAndDrop="True" TransferMode="Move"
                SelectionMode="Multiple" OnTransferred="radCompany_OnTransferred" EnableMarkMatches="True">
                <ButtonSettings TransferButtons="TransferFrom,TransferTo" ShowTransfer="True"></ButtonSettings>
            </telerik:RadListBox>
        </td>
        <td>
            <telerik:RadListBox runat="server" ID="radSelectedCompanies" Sort="Ascending" Width="265px" Height="200px" SelectionMode="Multiple"
                EnableMarkMatches="True">
            </telerik:RadListBox>
        </td>
    </tr>

    Code behind (C#):
    //loads list of companies
    private void LoadUserCompanies(int loginId)
    {
        var dtCompanies = _admin.GetMASCustomersForUser(loginId);
     
        radSelectedCompanies.ClearSelection();
        radSelectedCompanies.Items.Clear();
     
        radSelectedCompanies.DataSource = dtCompanies;
        radSelectedCompanies.DataValueField = "company_id";
        radSelectedCompanies.DataTextField = "company_id";
        radSelectedCompanies.DataBind();
    }
     
    protected void radCompany_OnTransferred(object sender, RadListBoxTransferredEventArgs e)
    {
        Sort();
    }
     
    private void Sort()
    {
        if (radCompany.Items.Any())
        {
          radCompany.SortItems();
        }
        if (radSelectedCompanies.Items.Any())
        {
          radSelectedCompanies.SortItems();
        }
    }

    Is there something I'm missing?
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 17 Mar 2015 Link to this post

    Hello,

    Please, run the attached sample project, which is using version 2015.1.225.45 of our controls, and try transferring items from one RadListBox to the other and vice versa. At my side it works correctly.

    Regards,
    Ivan Danchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike
    Mike avatar
    74 posts
    Member since:
    Mar 2013

    Posted 17 Mar 2015 in reply to Ivan Danchev Link to this post

    That project works.  What's different between your project and mine?
  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 20 Mar 2015 Link to this post

    Hello,

    The only difference between the code you posted and the one in the project I attached is the data binding. I bound the second RadListBox to an ArrayList, but that should not make any difference. Do you have custom javascript code executing on your page? If you do, using the browser's developer tools, you can check if there are any js errors on the page.

    Another thing to try, could you please place a break point on the radCompany_OnTransferred event handler and check if the event fires when transferring items from radSelectedCompanies to radCompany?

    Regards,
    Ivan Danchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Mike
    Mike avatar
    74 posts
    Member since:
    Mar 2013

    Posted 30 Mar 2015 in reply to Ivan Danchev Link to this post

    Sorry about the late response.  Yes, the radCompany_OnTransferred event does fire.  I can see the values of the transferred item as well as the source and destination boxes. 

    I did notice that the source data for radCompany is a DataTable and not a list whereas my "working" example (older version of Telerik) uses a List.  I guess DataTables are handled differently?

    I could write some logic to remove the item from the selected box and re-insert it into source box.  However, I'm curious as to why it works natively with an older version of Telerik, but the current version requires manual logic - or is this related to List vs DataTable?
  7. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 01 Apr 2015 Link to this post

    Hello,

    There should be no difference whether the RadListBox is bound to a DataTable or Dataset or any other data source. I am attaching the same project this time the ListBox is bound to a DataTable.

    You can try to debug the project and place a break point on the radCompany_OnTransferred event handler. Put e.Items.Count and e.Items[0].Text into a Watch pane to follow what is being transferred from one ListBox to the other.

    Regards,
    Ivan Danchev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  8. Mike
    Mike avatar
    74 posts
    Member since:
    Mar 2013

    Posted 09 Apr 2015 in reply to Ivan Danchev Link to this post

    Unfortunately, I had to solve the issue in the OnTransferred event to remove the item from one list and add it back to the other list.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017