I am trying to convert grid rows to arrays.
My requirement is to format table body into array. Each grid row is essentially an array. First index in the Body[] is for column headers, followed by each row.
I have managed to get gridHeaders in the required format (shown at bottom),
Required Format
table: {
body: [
gridHeaders,
["28", "CAIRNS", "12", "$9,737", "16", "$9,819"],
["16", "CAMBEL", "15", "$9,756", "18", "$9,687"]
]
}
Following is how I am building headers:
// Build Column Headers
var s = grid.getView().getGridColumns();
if (s.length > 1) {
for (var i = 0; i < s.length; i++) {
{
gridHeaders.push(s[i].text);
}
}
} //This correctly gives me column headers ["A","B","C","D","E",F"]
Following is how I am trying to build each row, but not getting it right and need assistance with. Note: It works fine if there is only one row. For multiple rows I need to somehow split gridRowContent.
// Build content. i.e. Rows
var t1 = Ext.pluck(grid.getStore().getRange(), 'data');
if (t1.length >= 1) {
for (var i = 0; i < t1.length; i++) {
debugger;
var rawRow = grid.getView().getNode(i).innerText;
var row = rawRow.split("n");
row = row.filter(function(v){return v!=='';});
for(var h in row){
gridRowContent.push(row[h]);
}
console.log(gridRowContent);
}
}
I know this is not the most elite way of doing this, but is there any other way?
Thanks. Any help will be appreciated.
Aucun commentaire:
Enregistrer un commentaire