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

Disable drag on row by row basis

3 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ronen Divon
Top achievements
Rank 1
Ronen Divon asked on 17 Mar 2009, 07:45 PM
I have AllowRowsDragDrop enabled on my grid, but have the need to disable it on a row by row basis. I thought adding an attribute of onmousedown return false would work, but that only worked in Firefox. Anyone do this? If so do you have any code?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2009, 08:19 AM
Hi Reverland,

Try the following code snippet for cancelling RowDrag event. Attach the function to OnRowDragStarted of RadGrid.

JavaScript:
<script type="text/javascript"
function OnRowDragStarted(sender, eventArgs) 
{     
    if(eventArgs.get_gridDataItem()._itemIndexHierarchical==1) 
    { 
        eventArgs.set_cancel(true//cancel the event 
        alert("Cannot drag this row"); 
    }     
function OnRowCreated() 
</script> 

Thanks,
Shinu.
0
Ronen Divon
Top achievements
Rank 1
answered on 18 Mar 2009, 01:08 PM
Hi Shinu,


Thanks for the code, but I am unclear on where to attach this function to. Do I add it to the onmousedown of the cell, row?
0
Princy
Top achievements
Rank 2
answered on 18 Mar 2009, 01:23 PM
Hello,

You can set the OnRowDragStarted client event  of the grid and use the code provided by Shinu to achieve your scenario.
aspx:
 <telerik:RadGrid ID="RadGrid" DataSourceID="SqlDataSource1" runat="server"
        <ClientSettings> 
        <ClientEvents OnRowDragStarted="RowDragStarted" />         
        </ClientSettings> 
      <MasterTableView > 

-Princy.
Tags
Grid
Asked by
Ronen Divon
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ronen Divon
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or