I just want to change the header, but now there is an extra expand animation that I don't need
|
changeTitle: function () {
this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = 'None'; this.$refs.acrdnInstance.ej2Instances.items[0].header = '123'; }, |
If the 'effect' is changed to 'None', then when the header is clicked to expand the content, there is no expansion animation.
I tried restoring animation after changing the header, but it doesn't work.
|
changeTitle: function () {
this.oldEffect = this.$refs.acrdnInstance.ej2Instances.animation.expand.effect; this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = 'None'; this.$refs.acrdnInstance.ej2Instances.items[0].header = '123'; }, expanding: function () { if (this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; } }, |
This will have another problem, when I collapse it first, and then change the title, it will be expanded at this time (It is not needed)
|
expanding: function (e) {
if (this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; e.cancel = true; } }, |
It's in the expanded state, changing the header will cause it to collapse .
Hi Bingxueyinlian,
You can use below customization to prevent the accordion item collapse.
App.vue:
export default Vue.extend({ data: function () { return { oldEffect: '', expandContent: false, } }, methods: { changeTitle: function () { this.oldEffect = this.$refs.acrdnInstance.ej2Instances.animation.expand.effect; this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = 'None'; this.$refs.acrdnInstance.ej2Instances.items[0].header = '123'; this.expandContent = this.$refs.acrdnInstance.ej2Instances.element.querySelector(".e-acrdn-panel").classList.contains("e-content-hide"); }, expanding: function (e) { if (this.expandContent && this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; e.cancel = true; this.expandContent = false; } }, } }); |
Could you please check the attached sample and confirm whether the above solution resolves the problem at your end?
Regards,
Satheesh Kumar B
This is only worked for the first item,if I change the header of the second item,It doesn't work.
this.$refs.acrdnInstance.ej2Instances.items[1].header = '123';
Sometimes I need to modify multiple headers at the same time , So, I want a general solution
Hi Bingxueyinlian,
You can use the below customization in changeTitle method to resolve the reported issue.
App.vue:
methods: { changeTitle: function () { this.oldEffect = this.$refs.acrdnInstance.ej2Instances.animation.expand.effect; this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = 'None'; this.$refs.acrdnInstance.ej2Instances.items[0].header = '123'; this.$refs.acrdnInstance.ej2Instances.items[1].header = '456'; this.content = this.$refs.acrdnInstance.ej2Instances.element.querySelectorAll(".e-acrdn-panel"); for (var i = 0; i < this.content.length; i++) { this.expandContent = this.$refs.acrdnInstance.ej2Instances.element.querySelectorAll(".e-acrdn-panel")[i].classList.contains("e-content-hide"); this.$refs.acrdnInstance.ej2Instances.items[i].expanded = !(this.expandContent); } }, expanding: function () { }, } |
Could you please check the attached sample and confirm whether the above solution resolves the problem at your end?
Regards,
Satheesh Kumar B
This is back to "no expansion animation"
Hi Bingxueyinlian,
Sorry for the inconvenience.
You can use the below customization in expanding event to restore the previous expand animation effect.
App.vue:
expanding: function (args) { if (!args.isExpanded && this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; } }, |
Could you please check the attached sample and confirm whether the above solution resolves the problem at your end?
Regards,
Satheesh Kumar B
There is also a little problem, change the title when collapse, and there is no animation for the first expansion
App.vue:
methods: { changeTitle: function () { this.oldEffect = this.$refs.acrdnInstance.ej2Instances.animation.expand.effect; this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = 'None'; this.$refs.acrdnInstance.ej2Instances.items[0].header = '123'; this.$refs.acrdnInstance.ej2Instances.items[1].header = '456'; this.content = this.$refs.acrdnInstance.ej2Instances.element.querySelectorAll(".e-acrdn-panel"); for (var i = 0; i < this.content.length; i++) { this.expandContent = this.$refs.acrdnInstance.ej2Instances.element.querySelectorAll(".e-acrdn-panel")[i].classList.contains("e-content-hide"); this.$refs.acrdnInstance.ej2Instances.items[i].expanded = !(this.expandContent); } }, clicked: function (args) { if (!(args.item.expanded) && this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; } }, } |
Could you please check the attached sample and confirm whether the above solution resolves the problem at your end?
Regards,
Satheesh Kumar B
In this version, after changing the title, there is no animation always when you click to expand.
App.vue:
methods: { expanding: function (args) { if (!(args.item.expanded) && this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; } }, clicked: function (args) { this.expandContent = args.originalEvent.target.parentElement.classList.contains("e-content-hide"); if (!(this.expandContent) && this.$refs.acrdnInstance.ej2Instances.animation.expand.effect === 'None') { this.$refs.acrdnInstance.ej2Instances.animation.expand.effect = this.oldEffect; } }, } |
Could you please check the attached sample and confirm whether the above solution resolves the problem at your end?
Regards,
Satheesh Kumar B
ok,it works.
thanks very much!
You are most welcome!!!