Discuss issues related to v5.x

Post by Scheuring »

Hi there,

How can I get access to the viewmodel data of the gantt panel inside de eventRenderer method? The scope is the ganttview and I couldn't find a link to the viewmodel there.


Post by saki »

According to Ext documentation, there's a getter method: https://docs.sencha.com/extjs/7.4.0/classic/Ext.Component.html#method-getViewModel so you should be able to call

var vm = this.getViewModel();

to get it (provided that this points to the view with that viewmodel).


Post by Scheuring »

This doesn't seem to work as you can see in the

Fiddle.js
(8.99 KiB) Downloaded 17 times

I took from your examples and modified a bit. Inside the eventRenderer function, this.getViewModel() returns null.

I'm working with
ExtGantt 5.1.8
Extjs 6.7

Regards


Post by mats »

this inside the eventRenderer points to the internal scheduler view instance. So just create a var me = this; outside and use it inside your eventRenderer

Tired of debugging javascript errors in web applications? Try our powerful error logging service RootCause


Post by Scheuring »

But how/where would I do that? Outside Ext.Apply, this is the viewport. What I need is the ganttpanel. Can you make it work with the fiddle?


Post by saki »

Try this:

        Ext.apply(this, {
            layout: 'border',
            
            items: [
                {
                    xtype           : 'ganttpanel',
                    itemId          : 'gantt',
                    title           : 'Gantt',
                    cls             : 'match-height-with-tools',
                    bodyBorder      : false,
                    eventBorderWidth: 0,
                    viewModel:{
                        type:'test'
                    },
                    
                    eventRenderer: function(_task, _store) {
                        var vm = this.ownerCt.ownerCt.getViewModel();
                        print(vm);
                    },

Post Reply