[TableSheet] Disable a specific date picker cell type

Posted by: lucas.nguyen on 6 December 2024, 12:23 am EST

    • Post Options:
    • Link

    Posted 6 December 2024, 12:23 am EST - Updated 6 December 2024, 3:40 am EST

    In TableSheet, is there a way to disable a specific cell type “date” (not entire column) with a datepicker button in a table sheet? Cancelling the edit starting event doesn’t work.

  • Posted 6 December 2024, 6:22 am EST - Updated 6 December 2024, 6:27 am EST

    Hi,

    Based on my understanding, you want to disable the date-time picker for specific cells, preventing it from opening for those cells.

    Although there is no direct API to achieve this, you can override the openDateTimePicker command, which is responsible for opening the date-time picker. When overriding, the options parameter provides details such as the row, column, and sheet name. Using this information, you can decide whether to call the original openDateTimePicker command or block it based on your logic.

    Refer to the snippet below, along with the attached GIF “Steps.gif” and the sample “Sample.zip”:

    let oldOpenDateTimeCmd = GC.Spread.Sheets.Commands.openDateTimePicker.execute;
    
    GC.Spread.Sheets.Commands.openDateTimePicker.execute = function () {
        let options = arguments[1];
        // Open the date-time picker only for even-numbered rows in column 5
        if (options.row % 2 === 0 && options.col === 5) {
            return oldOpenDateTimeCmd.apply(this, arguments);
        }
        return false;
    };

    Gif:

    Sample: Sample.zip

    References:

    Regards,

    Priyam

  • Posted 6 December 2024, 6:37 am EST

    It works, thank you very much!

Need extra support?

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

Learn More

Forum Channels