Selecting Items

7 posts, 0 answers
  1. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 10 Jul 2009 Link to this post

    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?

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 10 Jul 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 10 Jul 2009 Link to this post

    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.
  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 13 Jul 2009 Link to this post

    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.
  6. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 13 Jul 2009 Link to this post

    Hi Simon,

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

  7. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 14 Jul 2009 Link to this post

    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.
  8. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 22 Jul 2009 Link to this post

    Thanks.

    It's Ticket Number 229350
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017