We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Changing the value in an already created item

I had a problem changing the value. In one method when a form is created, I create a DateTimePicker. Also in the form there are buttons like time templates, when clicked, the template time should be set by template . When pressed, the value changes visually, but after submitting the form, the value is set to the original :(.
var editorTemplateVue = Vue.component('editorTemplate', {
template: `

<span class="button is-success is-selected" v-on:click="changeDate('1')">8:00 - 16:00</span>
     <input id="StartTime" ref="starttime" class="e-field" type="text" name="StartTime" />

`
,
data: function() {
return {
};
},

methods: {
changeDate: function (data) {
     let startDate = this.$refs.starttime.value;
     startDate = startDate.split(" ");
      this.$refs.startDate.value = endDate[0] + ' 16:00 ' + 'PM';

     },

}
},
}


export default Vue.extend({
data: function () {
return {

editorTemplate: function(e) {
return {
template: editorTemplateVue
}
}},
methods: {
onPopupOpen: function(args) {
if (args.type === 'Editor') {
let startElement = args.element.querySelector('#StartTime');

if (!startElement.classList.contains('e-datetimepicker')) {

let testtt = new DateTimePicker(
{value: new Date(startElement.value) || new Date(),
},
startElement
);
}
}

});

3 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team May 8, 2019 10:32 AM UTC

Hi Vadims 
 
Greetings from Syncfusion. 
 
We suspect that instance is not correct which could be the cause and kindly use the below code example. 
 
changeDate: function(data) { 
      let startDate = this.$refs.starttime.value; 
      startDate = startDate.split(" "); 
      this.$refs.starttime.ej2_instances[0].value = new Date( 
        new Date(startDate[0]).setHours(8) 
      ); 
      this.$refs.endTime.ej2_instances[0].value = new Date( 
        new Date(startDate[0]).setHours(16) 
      ); 
    } 
  } 
 
Regards,  
Karthi  
 



VT Vadims Talapins May 8, 2019 11:44 AM UTC

Hi Karthi,
Thanks a lot everything works as it should.
Syncfusion best!


KK Karthigeyan Krishnamurthi Syncfusion Team May 9, 2019 03:40 AM UTC

Most welcome 😊 


Loader.
Live Chat Icon For mobile
Up arrow icon