How to let DateTimePicker only enable dates that exist in db?

How to let DateTimePicker only enable dates that exist in db?

panzrampanzram Posts: 29Questions: 11Answers: 0

Hi,

I've been looking around and I couldn't find anything about this. Is there a way to only allow a user to select dates that are in the database, only enable dates that exist? ...or at least show a popup warning, or mark the non-existing dates in a different colour, or something similar, and that isn't too complicated and/or heavy on memory usage?

Thx.

This question has accepted answers - jump to:

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    Set up an ajax call that is triggered by a change event that goes back to the server and checks the date?

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    What date picker library are you using? Does it have the ability to selectively enable specific dates only?

    Allan

  • panzrampanzram Posts: 29Questions: 11Answers: 0

    Thanks for your replies!

    bindrid:
    I guess you mean that I need to check the date on the "after update" event and display a message if it's not valid. I am sort of thinking along those lines myself.

    Allan:
    I am using the standard one from the editor, didn't even know there was another. I've seen the disable date option in the example, but I'm not sure how I can apply that. I thought it was only a dayofweek exclusion to avoid weekends. I actually have several years of business dates, inc bank holidays, so the list would be rather long.

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Answer ✓

    I see what you mean - sorry - I had thought you were talking about filtering a DataTable, not limiting the options in Editor's date picker.

    Unfortunately that isn't something that is currently possible in the datetime field. You can disallow selection for certain days of the week, or use a max / min date, but there isn't the option to arbitrarily disable days in the calendar.

    The best I can think of (other than modifying the code of course) is to add a validator similar to what bindrid suggests.

    Allan

  • panzrampanzram Posts: 29Questions: 11Answers: 0

    Thank you both for your time! I will look into bindrid's suggestion.

This discussion has been closed.