We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Sfdatagrid Cell Drag and Drop

Hi Team

We are using SFDataGrid control in our application, so we need a requirement of cell drag and drop of  SFDataGrid cells.
So send me an appropriate snippet for this. 

Thanks 
Harshul

17 Replies

JN Jayaleshwari N Syncfusion Team December 26, 2018 09:42 AM UTC

Hi Brijesh,  
  
Thanks for contacting Syncfusion Support.  
  
Currently we does not have support to drag and drop between cells. Instead of this we would like to suggest you to use copy, paste actions to apply selected cell values with in the grid. You can copy one cell and paste it into multiple cells in SfDataGrid.  
 
  
Regards,  
Jayaleshwari N 



BR Brijesh January 1, 2019 09:38 AM UTC

Hi Team

I am using sfdatagrid control in which one column type is a button, I want to drag and drop that column button because at the dropping of a button I want to perform some operations. please send me an appropriate solution for my requirement otherwise give me some alternate solution according to my requirement.

Thanks 
Harshul


SP Shobika Palani Syncfusion Team January 2, 2019 03:42 PM UTC

Hi Brijesh, 

We have analyzed your query to perform some actions when dropping the button. As mentioned in our previous update, we would suggest you to use copy, paste actions to apply selected cell values within the grid. You can perform actions that you want to do on dropping of button in PasteGridCellContent event. Please find the following UG link for more details on customizing the paste action 
UG Link : 

Please refer the below KB articles which may help you 
KB article : 

Please let us know if you have any concern. 

Regards, 
Shobika. 



BR Brijesh January 14, 2019 12:02 PM UTC

Hi Team,

I am using SFDatagrid to display data. I have a scenario where I need to have multiple SFDatagrid in the same view with the same dataset such that one grid is scrolled and automatically other grids get scrolled to the same position. Is there any inbuilt feature in syncfusion which does this? If not kindly help me out on this.

Thanks
Harshul


JN Jayaleshwari N Syncfusion Team January 16, 2019 12:06 PM UTC

Hi Harshul, 
 
Thanks for contacting Syncfusion support. 
 
By default, SfDataGrid does not have built-in support to synchronize the scrollbar of one datagrid to another datagrid. However, you can be achieve your requirement by handling the ScrollChanged event. Please refer the below KB article for more information, 
 
Regards, 
Jayaleshwari N. 



BR Brijesh January 17, 2019 12:48 PM UTC

Hi Team,

I am using SFDataGrid Control, In which I' m using  GridTemplateColumn, In that template, I have three control Two TextBoxes and a Button And In SfDataGrid I' m using RowDragging and MouseLeftButtonUp events. So I 'm facing one issue, If I am writing something in TextBoxes at that time, Row is Dragging means Interchange up or down Row whenever I am writing something in a textbox. So I don't want this. So How to Overcome this Issue. Please Send me some appropriate solution on this.

I have attached an image for your reference below.

Thanks 
Harshul

Attachment: DraggingIssue_76e4286a.zip


SJ Sathiyathanam Jeyakumar Syncfusion Team January 18, 2019 01:27 PM UTC

Hi Harshul, 
 
Thanks for your update. 
 
We suspect your reported issue is “Entered textbox text is mismatch in GridTemplateColumn after applying the Row Drag Drop”, and this issue happened due to the entered text not hold in any property, so when apply the Row Drag and Drop the in top to bottom with scrolling , the rows only reused and the rows are not created, this is the default behavior of SfDataGrid. And you can avoid this problem by hold the textbox text with some property in model by using the below code snippets. 
 
Model.cs 
public string TextValue 
{ 
            get { return text; } 
            set { text = value; RaisePropertyChanged("TextValue"); } 
} 
 
ViewModel.cs 
orderCollection.Add(new Model(1001, "Maria Anders", "Germany", "ALFKI", "Berlin",string.Empty)); 
orderCollection.Add(new Model(1002, "Ana Trujilo", "Mexico", "ANATR", "México D.F.", string.Empty)); 
orderCollection.Add(new Model(1003, "Antonio Moreno", "Mexico", "ANTON", "México D.F.", string.Empty)); 
orderCollection.Add(new Model(1004, "Thomas Hardy", "UK", "AROUT", "London", string.Empty)); 
orderCollection.Add(new Model(1005, "Christina Berglund", "Sweden", "BERGS", "Luleå", string.Empty)); 
orderCollection.Add(new Model(1006, "Hanna Moos", "Germany", "BLAUS", "Mannheim",string.Empty)); 
 
MainWindow.xaml.cs 
 
<syncfusion:GridTemplateColumn HeaderText="DUMMY" MappingName="DUMMY"> 
    <syncfusion:GridTemplateColumn.CellTemplate> 
        <DataTemplate> 
            <Grid> 
                <Grid.ColumnDefinitions> 
                    <ColumnDefinition/> 
                    <ColumnDefinition/> 
                    <ColumnDefinition/> 
                </Grid.ColumnDefinitions> 
                <Button  Grid.Column="0"/> 
                <TextBox Grid.Column="1" Text="{Binding TextValue,Mode=TwoWay}"/> 
                <Button Grid.Column="2"/> 
            </Grid> 
        </DataTemplate> 
    </syncfusion:GridTemplateColumn.CellTemplate> 
</syncfusion:GridTemplateColumn> 
 
Please find the sample from the below location. 
 
Regards, 
Sathiyathanam 



BR Brijesh January 19, 2019 09:04 AM UTC

Hi Sathiyathanam Jeyakumar,

I think you didn't get my problem, I am already using model and binding model variable in my both textboxes and also binding mode is two way but still row is dragging up or down while entering something in any of the textboxes. One onDrop method is calling every time when I am trying to write in a textbox.

Below is my code snippet:- 


For your better clarity, I have attached a video below for your reference.

Thanks
Harshul

Attachment: DraggingIssue_8e603480.zip


SP Shobika Palani Syncfusion Team January 21, 2019 03:29 PM UTC

Hi Brijesh, 
 
Thanks for the update. 
 
We suspect that the reported issue is due to the customization that you have handled in RowDragging and MouseLeftButtonUp events. Could you please share the code snippet you have used to interchange the rows up or down. It will be helpful for us the reproduce the issue in our end. So that we could analyze and provide an appropriate solution at earlier.  
 
Regards, 
Shobika. 



BR Brijesh January 22, 2019 05:35 AM UTC

Hi Team,

I have created one sample for our above issue in which you can see when we focus on Template Column Textboxes or when we switch focus from one box to other then RowDragging happens up and down

I have attached a sample below.

Thanks 
Harshul

Attachment: SfDataGridDemo233667378_(2)_3ff7626a.zip


JP Jagadeesan Pichaimuthu Syncfusion Team January 23, 2019 11:15 AM UTC

Hi Brijesh, 
 
Thanks for the update. 
 
We have checked the provided sample and you can avoid the unwanted drag indicator shown after move focus from one textbox to other textbox or GridCell by using the below code snippets. 
 
protected override void ProcessPointerPressed(MouseButtonEventArgs args, RowColumnIndex rowColumnIndex) 
{ 
    var column = this.DataGrid.Columns[rowColumnIndex.ColumnIndex] is GridTemplateColumn; 
    if (!args.ChangedButton.ToString().Equals("Right") && !column) 
    { 
        MousePressed = true; 
    } 
    base.ProcessPointerPressed(args, rowColumnIndex); 
} 
 
 
protected override void ProcessPointerMoved(MouseEventArgs args, RowColumnIndex rowColumnIndex) 
{ 
      MousePressed = args.LeftButton == MouseButtonState.Pressed && MousePressed; 
} 
 
In the above code snippets, we have excluded the MousePressed true condition for GridTemplateColumn. 
   
Please find the sample form the below location. 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan


BR Brijesh January 23, 2019 12:51 PM UTC

Hi Team,

I want the GridTemplateColumn also to be dragged. Please help me on this as the solution provided does not solve this. Please update on the previous sample.

Thanks
Harshul

protected override void ProcessPointerPressed(MouseButtonEventArgs args, RowColumnIndex rowColumnIndex) 
{ 
    var column = this.DataGrid.Columns[rowColumnIndex.ColumnIndex] is GridTemplateColumn; 
    if (!args.ChangedButton.ToString().Equals("Right") && !column) 
    { 
        MousePressed = true; 
    } 
    base.ProcessPointerPressed(args, rowColumnIndex); 
} 
 
 
protected override void ProcessPointerMoved(MouseEventArgs args, RowColumnIndex rowColumnIndex) 
{ 
      MousePressed = args.LeftButton == MouseButtonState.Pressed && MousePressed; 
} 
 



SJ Sathiyathanam Jeyakumar Syncfusion Team January 24, 2019 12:27 PM UTC

Hi Brijesh, 
 
Sorry for the inconvenience caused. 
 
We are able to reproduce the reported “RowDragging happens up and down when switch focus from one box to other textbox” problem with the given sample and this issue happened from your RowDragAndDrop customization. The MousePreessed flag is true when you pressed the textbox of GridTemplateColumn in GridSelectionController<OrderInfo>.ProcessPointerPressed override method. As per your customization then the InitilizaPopupControl() method will be called and here you hook the events for dragggablePopupControl. So that only OnDrop method was called when you focus the textbox. 
 
You can avoid this problem by check the originalSource type name in GridSelectionController<OrderInfo>.ProcessPointerPressed override method.Now you can restrict the MousePressed true when you click the TextBox. Please refer the below code snippets. 
protected override void ProcessPointerPressed(MouseButtonEventArgs args, RowColumnIndex rowColumnIndex) 
{ 
    var typeName = args.OriginalSource.GetType().FullName; 
 
    if (!args.ChangedButton.ToString().Equals("Right") && typeName != "System.Windows.Controls.TextBoxView") 
    { 
        MousePressed = true; 
    } 
            
    base.ProcessPointerPressed(args, rowColumnIndex); 
} 
 
Please find the modified sample from the below location. 
 
Regards, 
Sathiyathanam


BR Brijesh January 28, 2019 10:58 AM UTC

Hello Team,

When I dragging template column in SFDatagrid then after one or two times dragging is being struck. And In my application, I have two template column in which left one is not dragging. Send me a solution to the previous sample.

Thanks
Harshul


JN Jayaleshwari N Syncfusion Team January 29, 2019 11:48 AM UTC

Hi Brijesh, 
 
Thanks for the update. 
 
We have checked the reported query and prepared simple sample based on the provided information by defining two template columns. Unfortunately the reported issue does not reproduced at our end. 
 
Please find the attached sample for your reference.  
 
Can you please check the attached sample if still the issue exists, could you please try reproducing it in the above sample or send us the reproducing steps so that we could sort out the cause of the issue and provide you a solution? If possible provide a gif or video of issue reproducing steps. 
 
Regards, 
Jayaleshwari N 



BR Brijesh January 29, 2019 01:05 PM UTC

Hello Team,

I have an attached a video below in which during dragging application is hanging.

Thanks
Harshul

Attachment: DraggingStruck_90d84010.zip


JN Jayaleshwari N Syncfusion Team January 30, 2019 12:24 PM UTC

Hi Brijesh, 
 
Thanks for the update. 
 
We suspect that the issue occurs due the customization used to provide row drag and drop support in the sample. SfDataGrid have direct support for row drag and drop and it can be enabled by using the property AllowDraggingRows and AllowDrop. 
 
We have modified and attached the sample based on the properties and you cam download the same from the following link. 
 
Check with the attached sample and revert us back if you would require further assistance.  
 
Regards, 
Jayaleshwari N 


Loader.
Live Chat Icon For mobile
Up arrow icon