RadListBox reordering event

15 posts, 0 answers
  1. Chuck
    Chuck avatar
    4 posts
    Member since:
    Mar 2011

    Posted 22 Mar 2011 Link to this post

    I am trying to use the drag-and-drop reordering capabilities of the list box control.  I see that there is an Index property in the EventArgs that seems to vary depending on where I drop the dragged list items.  I don't, however, understand the value of this property.  If I am moving items down in the list, Index seems to be the 0-based index of the item after which the dragged items have been dropped.  If I am moving items up in the list, the Index property seems to be 1 more than that.  Perhaps I am thinking of this incorrectly.  Could you please explain the expected behavior?  Thx.
  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 24 Mar 2011 Link to this post

    Hi Chuck,

    An event argument parameter contains the method get_offset(). It returns -1 when you are moving the item up and 1 when yo are moving item down.

    Kind regards,
    Peter Filipov
    the Telerik team
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chuck
    Chuck avatar
    4 posts
    Member since:
    Mar 2011

    Posted 24 Mar 2011 Link to this post

    The Offset field is set when one reorders items using the push buttons (up and down arrows) located next to the list.  When one uses the drag-and-drop method, the offset always appears to be 0 and the Index field seems to indicate the position in the list where the items are dropped.  My question is related to the drag-and-drop method of reordering.
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 28 Mar 2011 Link to this post

    Hi Chuck,

    If you are using the drag-and-drop functionality when the item is dropped the OnClientDropped client-event is fired. The get_dropPosition() property returns the relative position - either 0 (Above) or 1 (Below) toward the destination item. For more information please consult with the following help article.

    Regards,
    Peter Filipov
    the Telerik team
  6. Chuck
    Chuck avatar
    4 posts
    Member since:
    Mar 2011

    Posted 28 Mar 2011 Link to this post

    Actually, my problem is with using the server-side Reordering event in an effort to keep my database in sync with the GUI.
  7. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 31 Mar 2011 Link to this post

    Hello Chuck,

    RadListBox can perform transfer, delete and reorder operations and update the underlying data source control. Please check this demo overview for detailed information.

    Greetings,
    Peter Filipov
    the Telerik team
  8. Chuck
    Chuck avatar
    4 posts
    Member since:
    Mar 2011

    Posted 31 Mar 2011 Link to this post

    Thx.  It's good to know that the control can do some of the database work for me.

    However, I have not found a good explanation of the event args that are supplied to the Reordering event.  Is there somewhere an explanation of the properties, especially the Index property?
  9. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 31 Mar 2011 Link to this post

    Hello Chuck,

    The Index property gets/sets the position of the item which is reordered.
    For more information see this help article.

    The Offset always returns 0 instead -1 or 1.
    We are of this issue and we are going to fix it.

    Best wishes,
    Peter Filipov
    the Telerik team
  10. Chris
    Chris avatar
    28 posts
    Member since:
    Jun 2012

    Posted 04 Jun 2013 Link to this post

    Has the bug raised above ever been resolved?  I have Telerik 2012.2.912.35 and have just been trying to use the OnReordering event of the RadListBox so that when my list is re-ordered I can update the underlying database object but the e.Index is always 0 which means I can't tell if I have moved the item up or down in the list.

    Please can anyone tell me if there is a way server side to identify the items which have been reordered so that I can update the database.  If not I guess I will have to resort to Infragistics again...
  11. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 05 Jun 2013 Link to this post

    Hello Chris,

    The bug described in my previous post is resolved in Q3.2012. You could download that version or later release and test your project.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  12. Chris
    Chris avatar
    28 posts
    Member since:
    Jun 2012

    Posted 05 Jun 2013 Link to this post

    Unfortunately owing to a number of factors - including some issues with other controls - I do not have a current subscription and the last version I have is 2012.2.  Is it possible to get a patch or some update just for this one issue as I don't want to have to pay for another subscription especially for a bug which was already 18 months old when my subscription expired!
  13. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 05 Jun 2013 Link to this post

    Hi Chris,

    I dig deeper and found out that the issue is fixed even in Q2.2012. I have tested the problem and everything is working fine with the mentioned version. In case that you have different issue please send me sample code to reproduce or record a video which demonstrates it.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  14. Chris
    Chris avatar
    28 posts
    Member since:
    Jun 2012

    Posted 05 Jun 2013 Link to this post

    Definately not fixed in the release I have which is listed as 2012.2.912.35.  My .aspx is 

    <telerik:RadListBox ID="rlbStagesOnEvent" runat="server" AutoPostBack="true" 
    AllowReorder="True" AutoPostBackOnReorder="True" DataTextField="EventStageName" DataValueField="ID" 
    EmptyMessage="No Event Stages Defined" Height="100%" Width="100%"
    OnSelectedIndexChanged="rlbStagesOnEvent_SelectedIndexChanged" OnReordering="rlbStagesOnEvent_Reordering" />

    Note that I am loading an Object DataSource for the listbox.  Each EventStage object has an internal sequence number which is what I want to update in the database to reflect the change made.  My handler is 

    protected void rlbStagesOnEvent_Reordering(object sender, RadListBoxReorderingEventArgs e)
    {
    RadListBoxItem liToMove = rlbStagesOnEvent.Items[rlbStagesOnEvent.SelectedIndex];
    RadListBoxItem liOther = (e.Index == -1) ? rlbStagesOnEvent.Items[rlbStagesOnEvent.SelectedIndex - 1] : rlbStagesOnEvent.Items[rlbStagesOnEvent.SelectedIndex + 1];

    // Read the event stage definition back from the database 
    EventStage esToMove = new EventStage(int.Parse(liToMove.Value));
    EventStage esOther = new EventStage(int.Parse(liOther.Value));

    // Swap the sequence numbers over
    int oldSequence = esToMove.Sequence;
    esToMove.Sequence = esOther.Sequence;
    esOther.Sequence = oldSequence;
    esToMove.Update();
    esOther.Update();
    }

    I have uploaded a video of the program running in debug as 

    http://screencast.com/t/INxtXuma1m

    If I can't get this to work can I add my own buttons and then re-order the items manually server side?  If not I will have to give up with the Telerik suite as nothing I have tried so far has worked for me...
  15. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 05 Jun 2013 Link to this post

    Hi Chris,

    The offset issue is fixed. Regarding to the index of the reordering item you should use the following approach:
    protected void Unnamed_Reordering(object sender, Telerik.Web.UI.RadListBoxReorderingEventArgs e)
    {
        //e.Offset indicates whether the item is reorder up(-1) or down(1).
     
        //index of the reordering item
        var index = e.Items[0].Index;    
    }
    As soon as you tested the above code let me know if this resolves the case.

    Regards,
    Peter Filipov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  16. Chris
    Chris avatar
    28 posts
    Member since:
    Jun 2012

    Posted 05 Jun 2013 Link to this post

    Thanks - you are quite correct it was my error - I was using index rather than offset in my code.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017