Date-range

Tags: #<Tag:0x00007f8b1de79d98>

How could I implement a date-range option in my data?

I see there’s a date column type. I can use this to implement 2 columns: Start Date and End Date. However, how would I ensure that the range is valid, ie such that End Date doesn’t come before Start Date, or that if there’s a Start Date there must be an End Date, but both can be blank at the same time?

Hi @abeall

Maybe a custom validator?

I guess that you’d need to compare slices of a string in your predefined format (that is a requirement).

I would firstly check if the green value (parsed to a number) is greater and if they are qual go to the yellow value (in my case it is month) and the blue one at the end.

Trying to work this out… how do I know from the validator what row and column is currently being validated? I need to know this to figure out what other column in the same row needs to be compared with…

So I tried using a column validator() as well as the afterValidate() hook and ran into some issues, including this one… I ended up having better luck using beforeChanges() and splicing out dates that aren’t right, which includes considering the changes as a whole after being applied, for example pasting new Start and End dates, or just updating one of them, etc. It got surprisingly complicated!

A remaining issue: how do I make the datepicker only offer dates within the valid range? For example when I open the Start datepicker it should set the maxDate to the End date… but I’m not sure how to configure the datepicker on a per cell basis, or if that’s possible?

Hi @abeall

the afterValidate has a control over the cell coordinates via parameters fir the validator you access the object with settings via this statement like here http://jsfiddle.net/handsoncode/4p0zaxmr/

how do I make the datepicker only offer dates within the valid range?

Unfortunately, we do not have control over the range of dates. We can only validate them wrong.