I am working with vaadin-grid element but I am facing a problem.
At the moment I have an element which includes also a vaadin-grid and I try to access the grid after the element is ready in the following way:
Polymer({
is: 'my-element',
ready: function() {
// access my grid
var grid_by_id = this.$.mygrid; // return null
var grid_by_selector = document.querySelector('#mygrid'); // return null
}
})
And this is my DOM
But if I try to access in the same way the grid, after “a while, like few seconds later” the code works. So it looks to me that when Polymer fire the event “ready” inside the element my grid is not ready yet … Any idea how I can fix this?
This is a problem because I need to know when the DOM element “grid” is ready so I can start to play with it. What is supposed to be the right way?
ready: function (args) {
console.log(‘ready fired’);
console.log('ready > ’ + this.$.myGrid);
}
[/code]I get the following output from Google Chrome Console:
ready fired
ready > undefined
attached fired
attached > undefined
But if I search for this.$.myGrid later with a Button event or anything else, the grid is there. So it is really a problem of initialization of the vaadin-grid element.
If I put the grid inside a new tag that is using is=“dom-bind” or is=“dom-if” and I put a if clause, the grid is not rendered correctly and it doesn’t work as expected.