How to make DATETIME/DATE fields read-only on runtime?

28 views
Skip to first unread message

Manos Pappas

unread,
Sep 8, 2022, 2:42:28 PM9/8/22
to Jam.py Users Mailing List
Hello,

On a DATETIME field, we can turn the field into read-only using JQuery (as shown in the HowTo). For example, the following code makes the datestart DATETIME field read-only:

function on_edit_form_shown(item) {
    item.edit_form.find('input.datestart').prop('readonly', true); // make datestart RO
}

The code does makes the field read-only (so that its contents can be set programmatically) but both buttons before and after the field are still working, allowing the user to alter the proposed DATETIME value, which is not desirable. The parent object of the field (its container) does not have a read-only property.

What I want to do is either disable both buttons (the X and the calendar button) or hide them, so that the user cannot change the proposed DATETIME value.

How can this be done?

Thank you very much in advance for your help.

Danijel Kaurin

unread,
Sep 8, 2022, 2:47:30 PM9/8/22
to Manos Pappas, Jam.py Users Mailing List
Hi Manos.

Try instead: item.date_start.read_only = true;

Regards

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/2b8f8b30-1b18-4421-94ff-ffd4d5fe482an%40googlegroups.com.
Message has been deleted

Manos Pappas

unread,
Sep 9, 2022, 1:40:07 AM9/9/22
to Jam.py Users Mailing List
Hello,

That one worked, thank you :)
Reply all
Reply to author
Forward
0 new messages