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

Get Dropped RadListViewItem ID

1 Answer 62 Views
ListView
This is a migrated thread and some comments may be shown as answers.
James Shelton Agar
Top achievements
Rank 2
James Shelton Agar asked on 19 Jul 2010, 02:21 AM
Hi, I can get the sender id by args.get_itemIndex();, how can i get the destinationElement(which must also be a radlistviewitem) ID and/or clientvalue?

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 21 Jul 2010, 12:59 PM
Hi James,

I'm afraid that the destination item's index is not available, through itemdropping eventArgs. As RadListView is a "look-less control" it is hard to determine which portion of the rendered html it the actual item without cluttering the output with useless markup. Thus there is no client-side object representation of the data items.

However you can track the id of the destinationItem by hooking to its mouseover and mouseout events and saving the DisplayIndex in order to retrieve it from dropping handler. Similar to the following:

<div>
    <telerik:RadListView runat="server" ID="RadListView1">
        <ItemTemplate>
            <div class="rlvI">
                <telerik:RadListViewItemDragHandle ID="RadListViewItemDragHandle1" runat="server" />
                data....
            </div>
        </ItemTemplate>
        <ClientSettings AllowItemsDragDrop="true">
            <ClientEvents OnItemDropping="itemDropping" />
        </ClientSettings>
    </telerik:RadListView>
</div>
<div>
    <telerik:RadListView runat="server" ID="RadListView2">
        <ItemTemplate>
            <div class="rlvI" onmouseover='itemMouseOver("<%#Container.DisplayIndex %>")' onmouseout='itemMouseOut();'>
                data....
            </div>
        </ItemTemplate>
    </telerik:RadListView>
</div>
<script type="text/javascript">
    var currentDestinationIndex = -1;
    function itemDropping(sender, args) {
        var destIndex = currentDestinationIndex;
        alert("dragged item index:" + args.get_itemIndex());
        if (destIndex > -1) {
            alert("destination index:" + destIndex);
        }
        else {
            alert("Not over RadListView2 items");
        }
    }
    function itemMouseOver(displayIndex) {
        //save the id in a variable when dragged item is over
        currentDestinationIndex = displayIndex;
    }
    function itemMouseOut() {
        //clear the variable if dragged item leaves 
        //destination item boundaries
        currentDestinationIndex = -1;
    }
</script>

Greetings,
Rosen
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
ListView
Asked by
James Shelton Agar
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or