Disable user dragfill in column direction

Posted by: namratha.bejgam on 7 October 2021, 4:54 pm EST

  • Posted 7 October 2021, 4:54 pm EST

    Hi,

    Is there any way we can restrict the user drag and fill functionality in SpreadJS only to row direction (i.e., disable it in column direction)? Looks like there's no such apt option available currently.

    Thanks
  • Replied 7 October 2021, 4:58 pm EST

    namratha.bejgam said:
    Hi,

    Is there any way we can restrict the user drag and fill functionality in SpreadJS only to row direction (i.e., disable it in column direction)? Looks like there's no such apt option available currently.

    Thanks

    Here's the image for reference
  • Replied 10 October 2021, 6:33 pm EST

    Hi,

    For this, You may use the DragFillBlock event and cancel it if the direction is left or right. Please refer to the following code snippet and let me know if you face any issues.


    sheet.bind(GC.Spread.Sheets.Events.DragFillBlock, (e, args) => {
    if (
    args.fillDirection === GC.Spread.Sheets.Fill.FillDirection.right ||
    args.fillDirection === GC.Spread.Sheets.Fill.FillDirection.left
    )
    args.cancel = true;
    });


    DragFillBlock: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Events~DragFillBlock_EV.html


    Regards
    Avinash
  • Replied 11 October 2021, 6:07 pm EST

    avinash.pathak said:
    Hi,

    For this, You may use the DragFillBlock event and cancel it if the direction is left or right. Please refer to the following code snippet and let me know if you face any issues.


    sheet.bind(GC.Spread.Sheets.Events.DragFillBlock, (e, args) => {
    if (
    args.fillDirection === GC.Spread.Sheets.Fill.FillDirection.right ||
    args.fillDirection === GC.Spread.Sheets.Fill.FillDirection.left
    )
    args.cancel = true;
    });


    DragFillBlock: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Events~DragFillBlock_EV.html


    Regards
    Avinash


    The dragfill part works like a charm, thanks.
    But how do we handle the same for Copy-Paste?
  • Replied 12 October 2021, 4:56 pm EST

    Hi,

    Similarly, you could handle ClipboardPasting event and cancel the action if the range has more than one column. Please refer to the following code snippet and let me know if you face any issues.


    sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, (e, args) => {
    if (args.cellRange.colCount > 1) args.cancel = true;
    });


    ClipboardPasting: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Events~ClipboardPasting_EV.html

    Regards
    Avinash
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels