Our state of the art Gantt chart


Post by prem kumar »

Hi Team,

I am currently working with Bryntum’s Popup component and I’m facing a challenge with validating and handling changes to a DateTime field. My goal is to ensure that when the user attempts to change the datetimefield and hit save, it should throw validation something like modification is not possible and revert to the original value. have tried using events such as change and beforerender, but I haven’t been able to achieve the desired behavior.The code as follows

  bryntumRefs.current.exedocpopupRef = new Popup({
  //Existing code
  bbar:{
  items:{
  saveButton:{
  //Existing code for validating earlier and later dates
  }
  //---existing code
    {
                  type: "datetimefield",
                  label: "Shop TAT Start Date",
                  cls: "exedoc_date right",
                  ref: "shoptatstartdatefield",
                  dateField: {
                    format: "DD-MM-YYYY"  //userPreference.dateFormat,
                  },
                  timeField: {
                    format: userPreference.timeFormat,
                    editable: true,
                  },
  }}
  })

could u please suggest the workarounds to acheve it .

Thanks,
Prem Kumar


Post by khattakdev »

Hi there,

Here's a simple code:

const dateField = new DateTimeField({
    value      : new Date(2021, 0, 5, 12, 40),
    label       : 'Enter date & time',
    listeners : {
        change : (value) => {
            dateField.value = value.oldValue;
        }
    },
});

This will revert the value to the original/previous value.

Arsalan
Developer Advocate


Post Reply