1

Using the Dojo framework.

I have a 2 nested grid. Grid 1 uses a Dod with a detailprovider to load details on demand when one clicks a expand icon. When pressed this opens a nested grid. I need to track changes made in both grids. In the declaring class I've got an array that keeps track on changes made. The problem is that I can't access the array from a detailprovider. Since I've to conform to the protocol which gridx later invokes. What can I do to obtain a ref to the declaring class

var myDeclaringClass = declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin], {
    array: [],

    initGrid: function(){ 
        var grid = new Grid({
            store: store,
            structure: columns,
            modules: [ {
                  moduleClass: Dod,
                  showExpando: true,
                  detailProvider: this.myDetailProvider
            }]
        });

        // .... grid.placeAt() .. grid.startup()
    },

    myDetailProvider: function(parentGrid, rowId, detailNode, rendered) {
        // construct Nested Grid ...

        // How to obtain this reference here?
        // to access this.array?

        rendered.callback();
        return rendered;
    }
    retrun myDeclaring;
}

EDIT: I have also tried with a static var like:

statics: { array: [] }

But here I will stille need a instance ref to access it.

Mat0
  • 1,165
  • 2
  • 11
  • 27

1 Answers1

1

Try something like this

 var myDeclaringClass = declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin], {
        array: [],
var globalref : this,//here i'm assigning 'this' i.e. class level ref to the variable

        initGrid: function(){ 
            var grid = new Grid({
                store: store,
                structure: columns,
                modules: [ {
                      moduleClass: Dod,
                      showExpando: true,
                      detailProvider: this.myDetailProvider
                }]
            });

            // .... grid.placeAt() .. grid.startup()
        },

        myDetailProvider: function(parentGrid, rowId, detailNode, rendered) {
            // construct Nested Grid ...

            // How to obtain this reference here?
            // to access this.array?
    globalref.array//should give you access to the array
            rendered.callback();
            return rendered;
        }
        retrun myDeclaring;
    }
bajji
  • 1,271
  • 3
  • 15
  • 37