PDA

View Full Version : [CLOSED] Get grid rendered values



jchau
Dec 22, 2014, 10:17 PM
Is it possible to get record's rendered text instead of the raw store data? When exporting the grid, I want to get the text after it ran through my custom renderers. Store.GetRecordsValues returns the raw data.

Daniil
Dec 23, 2014, 10:21 AM
Hi @jchau,

It is definitely possible. At least, we do that in our GridPanel Print functionality. You could review, search for "renderer".
http://svn.ext.net/premium/branches/2/Ext.Net/Build/Ext.Net/extnet/src/grid/Print.js

As far as you can see we just call a Renderer for each value.

I think it is also possible to retrieve all the rendered values on the DOM level.

It seems there was a thread where I was helping with a similar request, but I don't remember exactly.

jchau
Dec 23, 2014, 2:27 PM
Thanks. I wrote a simple function to do this:



getGridSimpleHtml: function (grid) {
var columns = grid.columns,
rows = grid.getView().getNodes(),
html, i, j, row, cell;


html = '<table class="simple-table" style="width:100%">';


// build table headers
html += '<tr>';
for (i = 0; i < columns.length; i++) {
html += '<th style="width:' + columns[i].initialConfig.width + 'px">' + columns[i].text + '</th>';
}
html += '</tr>';


// build table rows
for (i = 0; i < rows.length; i++) {
html += '<tr>';
row = rows[i];
for (j = 0; j < row.cells.length; j++) {
cell = row.cells[j];
html += '<td>' + cell.innerText + '</td>';
}
html += '</tr>';
}
html += '</table>';
return html;
},