Drag Down Excel like event on SfDatagrid

Hello!

I was wondering if there is any way to capture a drag-down Excel-like event on a sfdatagrid. On Excel the user can hover over the bottom right of a cell, and drag it down, which will copy and paste the value in the cell they originally hovered over, to all the cells they highlighted as they dragged. Is there any event like this already created for the SfDatagrid, or anything similar that might work for this functionality?

This article covers the Excel event that I am trying to recreate on a sfdatagrid - https://edu.gcfglobal.org/en/excel-tips/a-faster-way-to-use-the-fill-handle/1/

Let me know if there are any other questions

Thank you!




3 Replies

JA Jacob October 19, 2023 01:02 PM UTC

Bumping



SG Santhosh Govindasamy Syncfusion Team October 19, 2023 01:20 PM UTC

Hi Jacob,

We are currently analyzing your reported scenario. We need time to validate the scenario, we will provide an update on or before October 24, 2023.


Regards,
Santhosh.G



SG Santhosh Govindasamy Syncfusion Team October 24, 2023 04:51 PM UTC

Jacob,

Based on the information you provided, we have created a sample to achieve your requirement. We accomplished this by overriding the "GridCutCopyPaste" class in the "PasteToCells" method.


The copy and paste behavior slightly differs from Excel. In the SfDataGrid, you need to copy the cell value using the (Ctrl+C) key, then select the cells for pasting, and finally, paste the value using the (Ctrl+V) key.


We have attached the sample and a video demo for your reference. If we missed anything, please share more details about this. This would be helpful for us to check and provide you with a solution as soon as possible.

Please refer the Code snippet

public MainWindow()

        {

            InitializeComponent();

            this.dataGrid.GridCopyPaste = new CustomCopyPaste(dataGrid);

          

        }

 

 

 

public class CustomCopyPaste : GridCutCopyPaste

    {

        public CustomCopyPaste(SfDataGrid sfgrid)

        : base(sfgrid)

        {

        }

        protected override void PasteToCells(object clipboardrows)

        {

            var data = (IList)clipboardrows;

            var firstrowdata = Regex.Split(data[0].ToString(), @"\t");

            //Gets the ClipboardText and checks when the clipboard text is more than one cell

            // calls the base.

            if (data.Count > 1 || firstrowdata.Count() > 1)

            {

               base.PasteToCells(clipboardrows);

                return;

            }

            //Gets the selected cells to paste the copied cell

            var selectedcells = this.dataGrid.GetSelectedCells();

            int selectedcellscount = selectedcells.Count;

            for (int i = 0; i < selectedcellscount; i++)

            {

                var record = selectedcells[i].RowData;

                var column = selectedcells[i].Column;

                //Calls PasteToCell method with particular record of selectedcells,

                // Column of selected records and rowdata

                PasteToCell(record, column, data[0]);

            }

 

        }

    }


Please refer the output:


Attachment: Copypaste_e8e0e2c6.zip

Loader.
Up arrow icon