RadListBack Default selected when transfered

4 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    29 posts
    Member since:
    Apr 2014

    Posted 05 Aug 2014 Link to this post

    Once I drag an item from one RadListBox to the TransferTo RadListBox, I want the item I just moved defaulted to selected in the TransferTo RadListBox. So when I drage a group from AllGroupsRadListBox into SharedGroupsRadListBox, I want the SharedGroupsRadListBox copy of the group to be selected so that the user can then do what he/she needs to do with the Group they just copied without having to then click on it again (my users are very click averse and quite vocal about it).<telerik:RadListBox runat="server" ID="AllGroupsRadListBox" Height="200px" Width="200px" AllowTransfer="true" SelectionMode="Single" TransferToID="SharedGroupsRadListBox" EnableDragAndDrop="true" OnClientSelectedIndexChanged="AllGroupsRadListBox_SelectedIndexChanged" />
    <telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px" /><br />
    Users in selected group:<br />
    <telerik:RadListBox runat="server" ID="UsersRadListBox" Height="200px" Width="200px" />
     
    private void FillAllGroups()
    {
     BWGroups allGroups = new BWGroups();
     allGroups.GetAllBWGroups();
     
     AllGroupsRadListBox.DataTextField = "BWGroupName";
     AllGroupsRadListBox.DataValueField = "BWGroupID";
     AllGroupsRadListBox.DataSource = allGroups.BWGroupList;
     AllGroupsRadListBox.DataBind();
     
    protected void AllGroupsRadListBox_SelectedIndexChanged(object sender, EventArgs e)
    {
    int parseGroupId = -1; Int32.TryParse(AllGroupsRadListBox.SelectedValue.ToString(), out parseGroupId);
      
    BWUsers usersInGroup = new BWUsers();
     
    if(parseGroupId > 0)
     usersInGroup.GetActiveBWUsersByGroupID(parseGroupId);
      
    UsersRadListBox.DataTextField = "BWGroupName";
    UsersRadListBox.DataValueField = "BWGroupID";
    UsersRadListBox.DataSource = usersInGroup.BWUserList;
    UsersRadListBox.DataBind();
    }
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2014 in reply to Jeremy Link to this post

    Hi Jeremy,

    Please try to attach the OnInserting ​event of SharedGroupsRadListBox ​and there set the each newly inserting item as selected. In order to select more than one Item try to set the SelectionMode of SharedGroupsRadListBox  to Multiple.

    ASPX:
    <telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px"
        SelectionMode="Multiple" OnInserting="SharedGroupsRadListBox_Inserting" />

    C#:
    protected void SharedGroupsRadListBox_Inserting(object sender, Telerik.Web.UI.RadListBoxInsertingEventArgs e)
    {
        foreach (RadListBoxItem item in e.Items)
        {
            item.Selected = true;
        }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeremy
    Jeremy avatar
    29 posts
    Member since:
    Apr 2014

    Posted 06 Aug 2014 in reply to Princy Link to this post

    Hi Princy,
    Thanks for the reply.  I tried what you suggested but I'm not able to get the event to fire.  I've tried both the OnInserting as well as the OnInserted.
    <telerik:RadListBox runat="server" ID="SharedGroupsRadListBox" Height="200px" Width="200px"
        AllowTransfer="true" SelectionMode="multiple" EnableDragAndDrop="true"
        TransferToID="AllGroupsRadListBox"
        AutoPostBack="true" OnInserting="SharedGroupsRadListBox_Inserting" OnInserted="SharedGroupsRadListBox_Inserted" />
     
    protected void SharedGroupsRadListBox_Inserting(object sender, Telerik.Web.UI.RadListBoxInsertingEventArgs e)
    {
        foreach (RadListBoxItem item in e.Items)
        {
            item.Selected = true;
        }
    }
     
    protected void SharedGroupsRadListBox_Inserted(object sender, RadListBoxEventArgs e)
    {
        foreach (RadListBoxItem item in e.Items)
        {
            item.Selected = true;
        }
    }


    But it's not getting into either method.
  5. Jeremy
    Jeremy avatar
    29 posts
    Member since:
    Apr 2014

    Posted 06 Aug 2014 Link to this post

    Found the problem.  Apparently it's not enough to set AutoPostBack="true" but there's also a AutoPostBackOnTransfer that needs to be set.  It's working now.  Thanks for your help Princy.
Back to Top