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

How to get a ordered items list after drag

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James O'Brien
Top achievements
Rank 1
James O'Brien asked on 09 Nov 2010, 03:29 PM
I'm looking to be able to handle the reorder myself in the server side RowDrop event using a post drag reordered list. I'll loop thru myself and reorder my data. Is that possible?

<telerik:RadGrid
    ID="gridQL"
    runat="server"
    AutoGenerateColumns="false"
    OnItemCommand="RadGrid_ItemCommand"
    Height="300"
    OnItemDataBound="RadGrid_ItemDataBound"
    OnRowDrop="grdPendingOrders_RowDrop">
    <MasterTableView DataKeyNames="HomeQuickLinkID">
        <Columns>
            <telerik:GridBoundColumn DataField="HomeQuickLinkID" Display="false"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LinkTitle" HeaderText="Link Title"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LongShowDate" HeaderText="Show Date"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LongUpdatedDate" HeaderText="Last Updated"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="UpdatedName" HeaderText="Last Updated By"></telerik:GridBoundColumn>
            <telerik:GridButtonColumn ButtonType="LinkButton" Text="Move Up" CommandName="UpQL"><ItemStyle Width="50px"></ItemStyle></telerik:GridButtonColumn>
            <telerik:GridButtonColumn ButtonType="LinkButton" Text="Move Down" CommandName="DownQL"><ItemStyle Width="70px"></ItemStyle></telerik:GridButtonColumn>
            <telerik:GridButtonColumn ButtonType="LinkButton" Text="Edit" CommandName="EditQL"></telerik:GridButtonColumn>
            <telerik:GridButtonColumn ButtonType="LinkButton" Text="Delete" CommandName="DeleteQL"></telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings EnablePostBackOnRowClick="true"  AllowRowsDragDrop="True">
        <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true"/>
    </ClientSettings>
</telerik:RadGrid>

protected void grdPendingOrders_RowDrop(object sender, GridDragDropEventArgs e)
    {
        int o = 0;
        NextGen.core.CMS.HomeQuickLinkManager m = new NextGen.core.CMS.HomeQuickLinkManager();
        foreach (GridDataItem i in e.[ReorderedItemsLists])
        {
            o = o + 1;
            m.EditOrder((int)draggedItem.GetDataKeyValue("HomeQuickLinkID"), o);           
        }
        LoadGrid();
    }

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 12 Nov 2010, 03:25 PM
Hello James,

There should be no problem reordering the rows manually. You just need to change their order in the datasource and rebind the grid, as demonstrated in our online demo (take a look in the code behind at the case where the OwnerGrid is the first grid itself).

Greetings,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
James O'Brien
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or