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

Selecting Items

6 Answers 382 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Nathan J Pledger
Top achievements
Rank 2
Nathan J Pledger asked on 10 Jul 2009, 09:21 AM
Hi (again),

I have the following ListView definition:

<telerik:RadListBox ID="radListBoxGroups" runat="server" 
                                                    AllowDelete="false"  
                                                    AllowReorder="false" 
                                                    AllowTransfer="true" 
                                                    AllowTransferDuplicates="false" 
                                                    AllowTransferOnDoubleClick="true" 
                                                    CheckBoxes="false" 
                                                    SelectionMode="Multiple" 
                                                    TransferMode="Move" 
                                                    Height="300" 
                                                    Width="180" 
                                                    TransferToID="radListBoxGroupsSelected" 
                                                > 
                                                    <ButtonSettings Position="Right"  
                                                        RenderButtonText="false"  
                                                        ShowDelete="false"  
                                                        ShowReorder="false"  
                                                        ShowTransfer="true"  
                                                        ShowTransferAll="false"  
                                                        VerticalAlign="Middle" /> 
                                                </telerik:RadListBox> 
                                                <telerik:RadListBox ID="radListBoxGroupsSelected" runat="server" 
                                                    Height="300" Width="170"
                                                </telerik:RadListBox> 

And I use the following code to populate it:

            var query = from dg in _dataGroups 
                        join dgi in _originalDataGroupItems on dg.ID equals dgi.ParentDataGroup.ID into sr 
                        from x in sr.DefaultIfEmpty() 
                        select new { DataGroupID = dg.ID, IsEnabled = x != null, DataGroupName = dg.Name }; 
 
            foreach (var q in query) 
            { 
                RadListBoxItem radListBoxItem=new RadListBoxItem(q.DataGroupName,q.DataGroupID.ToString()); 
                radListBoxGroups.Items.Add(radListBoxItem); 
                if (q.IsEnabled) 
                { 
                    radListBoxItem.Selected = true;                  
                } 
            } 

I have traced through and some items are set to Selected==true, yet the ListView does not reflect this. The UI does not move items to the right-hand list and the SelectedItems collection returns Count==0.

What am I doing wrong?

6 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 10 Jul 2009, 02:16 PM
Hi Nathan J Pledger,

I tried reproducing the issue with the provided RadListBox definitions and static data without success - Items were properly transferred between ListBoxes. Additionally, on postback the SelectedItems property of both ListBoxes returned the correct selected Items.

Without looking at your complete code I will be unable to determine what is causing these issue at your side.

Do you receive any JavaScript errors on the page?

Kind regards,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Nathan J Pledger
Top achievements
Rank 2
answered on 10 Jul 2009, 02:27 PM
Hi Simon,

I'm afraid I don't have a JS error. Further, I can move the items into the selected box on the right myself using the UI.

If I post the full (well, relevant) code for the form maybe that would highlight if I am doing something wrong at some point in the page lifecycle.

 
 
namespace IWW.MIGTurbo2.ASPNET.Presentation.Secure.Dialogs.Data 
 
    public partial class EditClient : MIGTurboPage  
    { 
 
        protected void Page_Load(object sender, EventArgs e) 
        {            
 
            using (ISession session = AspNetSessionFactory.GetSession()) 
            { 
                 
 
                _client = null
 
// assume client is retrieved here 
 
                if (!IsPostBack) 
                { 
 
                    PopulateForClient(_client,session); 
                } 
            } 
 
        } 
 
 
        private void PopulateDataGroupsListView(ISession session) 
        { 
            var query = from dg in _dataGroups 
                        join dgi in _originalDataGroupItems on dg.ID equals dgi.ParentDataGroup.ID into sr 
                        from x in sr.DefaultIfEmpty() 
                        select new { DataGroupID = dg.ID, IsEnabled = x != null, DataGroupName = dg.Name }; 
 
            foreach (var q in query) 
            { 
                RadListBoxItem radListBoxItem=new RadListBoxItem(q.DataGroupName,q.DataGroupID.ToString()); 
                radListBoxGroups.Items.Add(radListBoxItem); 
                if (q.IsEnabled) 
                { 
                    radListBoxItem.Selected = true;                  
                } 
            } 
        } 
 
         
 
         
        private void PopulateForClient(IClient client, ISession session) 
        { 
// field populate here 
 
            PopulateDataGroupsListView(session); 
        } 
 
         
    } 
 

I haven't got to working with the PostBack just yet.
0
Simon
Telerik team
answered on 13 Jul 2009, 02:00 PM
Hello Nathan J Pledger,

Your code is correct, so there should be something else causing the issue.

Could you verify that data base query returns correct information (i.e. there are records with IsEnabled == true)?

Greetings,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Nathan J Pledger
Top achievements
Rank 2
answered on 13 Jul 2009, 03:09 PM
Hi Simon,

I can confirm that some items come back in both IsEnabled==true and IsEnabled==false.

0
Simon
Telerik team
answered on 14 Jul 2009, 01:19 PM
Hi Nathan J Pledger,

Since I am still unsure of what is causing the issue you are describing, it would be best if you open a formal support ticket and send us the page or the project (if needed to reproduce the issue).

We will inspect and debug it thoroughly, eventually providing a solution or a workaround.

Best wishes,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Nathan J Pledger
Top achievements
Rank 2
answered on 22 Jul 2009, 03:17 PM
Thanks.

It's Ticket Number 229350
Tags
ListBox
Asked by
Nathan J Pledger
Top achievements
Rank 2
Answers by
Simon
Telerik team
Nathan J Pledger
Top achievements
Rank 2
Share this question
or