This is a migrated thread and some comments may be shown as answers.
Date validation based on other cell value
1 Answer 7 Views
This is a migrated thread and some comments may be shown as answers.
Maryia
Top achievements
Rank 1
Maryia asked on 11 Apr 2019, 06:22 PM
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"
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar
Telerik team
answered on 15 Apr 2019, 01:18 PM
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. 

Regards,
Petar
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.
Asked by
Maryia
Top achievements
Rank 1
Answers by
Petar
Telerik team
Share this question
or