This is a migrated thread and some comments may be shown as answers.
Problem Adding to Multiple ListBoxes from Client
1 Answer 29 Views
This is a migrated thread and some comments may be shown as answers.
Dev Dev
Top achievements
Rank 1
Dev Dev asked on 24 Aug 2009, 07:04 PM
Hi there,

I have a tab strip with a pair of listboxes (sources and destination) on each. I have one additional single listbox on another tab. This other listbox consolidates all of the selected items from each of the other listboxes under the other tabs. I am having trouble getting the consolidated ("lbYourChoices") show the added items. I have no trouble transferring to the paired listbox, but my issue is updating the other lb. I have tried everything I can think of. I am sure I am missing the obvious:

Thanks!

 


 

function ClientTransferring(sender, e)

 

 

{

 

var lbChoices = $find("<%= lbYourChoices.ClientID %>");

 

 

var newitems = lbChoices.get_items();

 

 

e.set_cancel(

true);

 

 

 

var items = e.get_items();

 

 

for (var i = 0; i < items.length; i++)

 

{

 

var item = items[i];

 

 

var itemx = new Telerik.Web.UI.RadListBoxItem();

 

 

itemx = items[i];

 

if (item.get_text() != "Select item(s)") {

 

lbChoices.trackChanges();

lbChoices.get_items().add(itemx);

lbChoices.commitChanges();

sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox());

}

 

}

 

}

 

 

 

 

<telerik:RadPageView ID="RadPageView7" runat="server">

 

 

<telerik:RadListBox ID="lbYourChoices" runat="server" AllowDelete="True"

 

 

style="top: 15px; left: 0px; height: 150px; width: 225px"

 

 

Height="175px" Width="225px" AutoPostBack="True">

 

 

 

 

 

 

</telerik:RadListBox>

 

 

 

 

 

 

</telerik:RadPageView>

 

 

 

 

 

 

 

<telerik:RadPageView ID="RadPageView1" runat="server">

 

 

 

 

 

 

<asp:RadioButtonList ID="RadioButtonList1" runat="server"

 

 

RepeatDirection="Horizontal"

 

 

style="top: 15px; font-family: Arial, Helvetica, sans-serif; font-size: x-small">

 

 

 

 

 

 

<asp:ListItem Selected="True">List View</asp:ListItem>

 

 

 

 

 

 

<asp:ListItem>Tree View</asp:ListItem>

 

 

 

 

 

 

</asp:RadioButtonList>

 

 

 

 

 

 

<telerik:RadListBox ID="RadListBox3" runat="server" AllowTransfer="True"

 

 

DataKeyField="item_id" DataSortField="item_id" DataSourceID="obj_Accounts"

 

 

DataTextField="item_name" DataValueField="item_id"

 

 

style="top: 15px; left: 0px; height: 150px; width: 175px"

 

 

TransferToID="RadListBox4" Height="150px"

 

 

AllowTransferOnDoubleClick="True" EnableDragAndDrop="True" Width="180px"

 

 

 

 

 

 

OnClientTransferring="ClientTransferring">

 

 

</telerik:RadListBox>

 

 

 

 

 

 

 

<telerik:RadListBox ID="RadListBox4"

 

 

style="top: 15px; left: 0px; height: 150px; width: 175px"

 

 

AllowTransferOnDoubleClick="True" EnableDragAndDrop="True" runat="server"

 

 

Height="150px" Width="180px"

 

 

AutoPostBack="True"

 

 

AutoPostBackOnTransfer="True"></telerik:RadListBox>

 

 

 

 

 

 

 

<asp:ObjectDataSource ID="obj_Accounts" runat="server"

 

 

OldValuesParameterFormatString="original_{0}" SelectMethod="GetByDimensionName"

 

 

TypeName="fvTempDAL.DimensionItemsDataSetTableAdapters.DimensionItems">

 

 

 

 

 

 

<SelectParameters>

 

 

 

 

 

 

<asp:Parameter DefaultValue="Accounts" Name="DimensionName" Type="String" />

 

 

 

 

 

 

</SelectParameters>

 

 

 

 

 

 

</asp:ObjectDataSource>

 

 

 

 

 

 

<br />

 

 

 

 

 

 

</telerik:RadPageView>

 

 

 


 


1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 27 Aug 2009, 01:03 PM
Hello there,

When you create the new ListBoxItem, please set its Text and Value properties like this:

itemx.set_text(items[i].get_text()); 
itemx.set_value(items[i].get_value()); 

instead of:

itemx = items[i]; 

Best wishes,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Asked by
Dev Dev
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or