Conditionally making cell required

Conditionally making cell required

arnorbldarnorbld Posts: 123Questions: 23Answers: 1

Hi guys,

I have a table with inline editing. I have a need to set a date field as a required field after another column of data is set to a certain value.

In my case, I have a status drop-down and a date popup. One of the options in the drop-down is to mark the row "Done" At that point, a "Complete date" cell must be updated. Data is saved when the dropdown value is selected or a date is selected from the date popup.

How can I enforce a date selection in this cell when a certain status is selected in another cell?

Best regards,

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You would use preSubmit there, which cancel the submit and display an error message. This example is similar to what you want to do - here's it's doing additional checks (such as confirming it's inline editing) but you would do something similar, just checking the value of the select field, then confirming the date isn't empty.

    Another option, if you want the date field to update automatically with today's date, would be set the date automatically with dependent() - see an example of that here.

    Colin

  • arnorbldarnorbld Posts: 123Questions: 23Answers: 1

    Hi Colin,

    I had actually started down the road with preSubmit, but the problem is that they would normally select the changed status BEFORE setting the completion date. I will check if setting the completion date to today's date is acceptable. Each cell is saved automatically to SQL when a selection is made. So I would never have a submit since the date wasn't selected...

    Essentially I need something that forces them to select a date. Maybe I could programmatically trigger the date selection popup for the completion date?

    Best regards,

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited July 2021

    Maybe I could programmatically trigger the date selection popup for the completion date?

    You could try field().focus(), that would force the user into that field,

    Colin

  • arnorbldarnorbld Posts: 123Questions: 23Answers: 1

    Hi Colin,

    Thank you, will try that!

Sign In or Register to comment.