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

Disable drag on row by row basis

1 Answer 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Deepak
Top achievements
Rank 1
Deepak asked on 18 Aug 2011, 11:05 AM
I have AllowRowsDragDrop enabled on my grid, but have the need to disable it on a row by row basis
in my Grid I have a GridCheckBoxColumn 

<

 

 

telerik:GridCheckBoxColumn DataField="IsChildDictionary" Visible="false" UniqueName="IsChildDictionary" DataType="System.Boolean" AllowFiltering="false">

 


on the basis of this checkbox state I want to disable darg and drop feature of row please suggest me how can I check the state of this checkbox ?

I want to use this condition in below function to disable drag and drop feature on row
function OnRowDragStarted(sender, eventArgs) 
{     
}
     

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 22 Aug 2011, 03:43 PM
Hi Deepak,

Desired functionality could be achieved using the following JavaScript code:

function OnRowDragStarted(sender, eventArgs)
       {
           var cell = eventArgs.get_gridDataItem().get_cell("IsChildDictionary");
           var checked = cell.children[0].children[0].checked;
           if (checked == "true") {
               eventArgs.set_cancel(true)
           }  
       }

Note that the provided code snippet, will not work with Visible property set to False. You need either to set Display property to False or add the name of the column in ClientDataKeyNames array. If you choose the second option the code in the event handler should be changed as follows:

function OnRowDragStarted(sender, eventArgs){
           if (eventArgs.get_gridDataItem().getDataKeyValue("IsChildDictionary")) {
               eventArgs.set_cancel(true);
           }
       }     

And MasterTableView tag should look like that:

<MasterTableView DataKeyNames="IsChildDictionary" ClientDataKeyNames="IsChildDictionary">



Best wishes,
Andrey
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Deepak
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or