Nic5
(Nic Stelter)
February 16, 2017, 7:49pm
1
Hello - can someone help add a select dropdown to the Polymer Grid component?
I have the following code in my Polymer component:
Name
Role
Job Number
Product
Pod
Location
Offer Status
Start Date
test
test
test
test
test
test
test
test
attached: function() {
var employeeTable = document.getElementById(‘employeeTable’);
employeeTable.columns = [
{name: ‘employee’},
{name: ‘role’},
{name: ‘jobNumber’},
{name: ‘product’},
{name: ‘pod’},
{name: ‘location’},
{name: ‘offerStatus’},
{name: ‘startDate’},
];
employeeTable.columns[3]
.renderer = function(cell) {
cell.element.innerHTML= “Option 1Option 2Option 5Option 4”;
};
}
If I call employeeTable.columns it returns no columns unless I explicitly set the columns (like I do in the attached function)
Any feedback is greatly appreciated, thank you.
virkki
(Tomi Virkki)
February 17, 2017, 1:54pm
2
Hello, Nic
The problem here is that the 1 initialized the columns asynchronously. Meaning that they’re not present yet at attached phase.
You can wrap the lines that set the column renderer inside “grid.then” to make sure the columns have been initialized:
employeeTable.then(function () {
employeeTable.columns[3]
.renderer = function(cell) {
cell.element.innerHTML= "<select id='commonSelect'><option>Option 1</option><option>Option 2</option><option selected>Option 5</option><option>Option 4</option></select>";
};
});
I highly recommend trying out 2 though, which makes all this a lot easier. It’s currently at alpha stage but we’re currently preparing it for beta release.
Latest release:
https://github.com/vaadin/vaadin-grid/releases/tag/v2.0.0-alpha2
Live demos:
https://cdn.vaadin.com/vaadin-grid/2.0.0-alpha2/demo/