Reputation: 9
I am working on application that requires Dojo grids to be used but I want to write the HTML for the table layout myself and use Dojo to insert the store data.
Is there a way with either dGrid or GridX to accomplish this, or is there a way to dynamically build tables/grids using the Dojo store?
Upvotes: 0
Views: 328
Reputation: 10559
If you're asking if dgrid or gridx can literally just shove data into an existing table element in-place, the answer is no. You could do that directly with a dojo/store by calling the query
method and adding a row for each result.
Here's the general idea:
var columnFields = [...];
store.query().forEach(function (item) {
var row = domConstruct.create('tr');
for (var i = 0, len = columnFields.length; i < len; i++) {
var cell = domConstruct.create('td', {}, row);
// Add the field value to a text node rather than setting as innerHTML
// to avoid unwanted tag injection
cell.appendChild(document.createTextNode(item[columnFields[i]));
}
tbody.appendChild(row);
});
The closest you can get to this idea with dgrid is dgrid/GridFromHtml, which will let you define the grid's structure using a table with thead and header cells. Combine that with OnDemandGrid or Pagination for store support.
As far as I know, gridx does not have something similar to this at all.
Upvotes: 1