Date validation based on other cell value

2 posts, 1 answers
  1. Maryia
    Maryia avatar
    3 posts
    Member since:
    Jan 2018

    Posted 11 Apr 2019 Link to this post

    I would like to use a custom formula on date validation: similar to this approach. Although I need the cell editor to be a datepicker (calendar view).

    Something like this, although it shows empty calendar
    validation: {                 
      dataType: "date",
      from: "B1",
      to : "C1"
      allowNulls: true,
      type: "reject",
      titleTemplate: "Date validaiton error",
      messageTemplate: "Invalid date"
  2. Answer
    Petar avatar
    462 posts

    Posted 15 Apr 2019 Link to this post

    Hello Maryia,

    To add DatePicker to a SpreadSheet cell in addition to your code you should add showButton configuration to this cell. 

    This Dojo shows how you could define custom date range by setting the start and the end date of a third DatePicker cell. In this case, cell B1 is setting the start date and D1 is setting the end date of C2 DatePicker cell. 

    Here comes the custom formula you've asked for. You can see the from configuration of cell C2 in the provided example. It is defined using a formula that checks if there is a date picked in cell B2. If a date is not selected in B2, then the start date of C2 DatePicker is set to 1 January 2019.

    So to answer your question, you can leave the dataType of the cell you want to use as DatePicker to "date" and write your custom formula in the form and to validation config.
    You could also find useful this Custom cell editors demo from our documentation. 

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top