'Vis Timeline - I don't want to change item.start and move. But i need to change item.end?
I have one item. And item is fixed for item.start, and item shall not be moved. I need to change just item.end.
I was trying something. For example if item.class name is record-scheduled, item.start should be in the future. This code worked. But I couldn't build for start is constant.
onMoving: function (item, callback) {
if(item.className == 'record-scheduled'){
var min = moment()
var max = moment(item.start).add(6,'hours')
if (item.start < min) item.start = min;
if (item.start > max) item.start = max;
if (item.end > max) item.end = max;
callback(item); // send back the (possibly) changed item
}else if(item.className == 'record-finished'){
callback(null)
}else if(item.className =='record-active'){
callback(item)
}
else{
callback(item)
}
},
My timeline options:
options: {
editable: true,
stack: false,
start:moment().format(),
}
explain is briefly:
else if(item.className =='record-active'){
item.start = 'cannot be changed'
item.end = 'can be change'
item.draggable = 'cannot be draggable'
}
How could i solve it?
Thanks, Regards.
Solution 1:[1]
I thought of a new solution while opening the thread. Maybe It's not best way but the way worked for me. But you have to database. I didn't find how to get beforeItemStart other way. Maybe somebody help us for this. And my my solution is like;
else if(item.className =='record-active'){
axios
.get('http://localhost:3000/' + item.id)
.then(response => (this.selectedItem = response.data))
var findstarttime = new Long(this.selectedItem.StartDateTime.Ticks.low,
this.selectedItem.StartDateTime.Ticks.high,false).toNumber();
var oneZeroGoneFindStartTime = findstarttime / 10000
var findedstarttime = moment(oneZeroGoneFindStartTime)
console.log(findedstarttime)
var beforeItemStart = findedstarttime
if(beforeItemStart < item.start) item.start = beforeItemStart;
if(beforeItemStart > item.start) item.start = beforeItemStart;
callback(item)
}
I find beforeItemStart and It's always item.start = beforeItemStart. And It can't draggable, just I can change end range. But here an axios causes too many queries. I need to fix that. Maybe it will be a solution for someone until a better answer comes.
Thanks, Regards.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mert |
