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

Issue With Transferring Items

6 Answers 119 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 13 Mar 2015, 10:43 PM
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?

6 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 17 Mar 2015, 04:59 PM
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.

 
0
Mike
Top achievements
Rank 1
answered on 17 Mar 2015, 08:17 PM
That project works.  What's different between your project and mine?
0
Ivan Danchev
Telerik team
answered on 20 Mar 2015, 02:02 PM
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.

 
0
Mike
Top achievements
Rank 1
answered on 30 Mar 2015, 05:13 PM
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?
0
Accepted
Ivan Danchev
Telerik team
answered on 01 Apr 2015, 02:21 PM
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.

 
0
Mike
Top achievements
Rank 1
answered on 09 Apr 2015, 11:28 PM
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.
Tags
ListBox
Asked by
Mike
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Mike
Top achievements
Rank 1
Share this question
or