jQWidgets Forums
jQuery UI Widgets › Forums › TreeGrid › TreeGrid cellClassName export
This topic contains 5 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 2 months ago.
-
Author
-
Hi,
i have a TreeGrid with cellClassName for colored rows.
When i export the TreeGrid, in the funktion of cellcClassName it gives an Error:
TypeError: rowData is undefinedThis is my fuction:
function cellColor(row, dataField, cellText, rowData) {
…
}
and this is in treegid:
{ text: ‘Summe ∑’, dataField: ‘sum’, cellsalign: ‘right’, align: ‘right’, width: ‘15%’, cellClassName: cellColor}Hi simcon94,
Could you provide a sample which demonstrates such behavior? We cannot reproduce it with jQWidgets 3.2.1.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI try it with the new version at first.
But can i do somthing like this?for (var i = 0; i < 3; i++) { //console.log(i); $('#treeGrid' + i).jqxTreeGrid('exportData', 'xls'); }
it only shows me one treegrid in Excel….
Hi simcon94,
No, you cannot do such thing.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI copied two examples to one project.
This Project throws the same error
TypeError: rowData is undefined
var cellValue = rowData[dataField];$(document).ready(function () { var cellClass = function (row, dataField, cellText, rowData) { var cellValue = rowData[dataField]; if (cellValue < 100000) { return "min"; } if (cellValue < 200000) { return "minavg"; } if (cellValue < 400000) { return "avg"; } return "max"; } var data = [ { "id": "1", "name": "Corporate Headquarters", "budget": "1230000", "location": "Las Vegas", "children": [ { "id": "2", "name": "Finance Division", "budget": "423000", "location": "San Antonio", "children": [ { "id": "3", "name": "Accounting Department", "budget": "113000", "location": "San Antonio" }, { "id": "4", "name": "Investment Department", "budget": "310000", "location": "San Antonio", children: [ { "id": "5", "name": "Banking Office", "budget": "240000", "location": "San Antonio" }, { "id": "6", "name": "Bonds Office", "budget": "70000", "location": "San Antonio" }, ] } ] }, { "id": "7", "name": "Operations Division", "budget": "600000", "location": "Miami", "children": [ { "id": "8", "name": "Manufacturing Department", "budget": "300000", "location": "Miami" }, { "id": "9", "name": "Public Relations Department", "budget": "200000", "location": "Miami" }, { "id": "10", "name": "Sales Department", "budget": "100000", "location": "Miami" } ] }, { "id": "11", "name": "Research Division", "budget": "200000", "location": "Boston" } ] } ]; var source = { dataType: "json", dataFields: [ { name: "name", type: "string" }, { name: "budget", type: "number" }, { name: "id", type: "number" }, { name: "children", type: "array" }, { name: "location", type: "string" } ], hierarchy: { root: "children" }, localData: data, id: "id" }; var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function () { } }); $("#treeGrid").jqxTreeGrid( { width: 670, source: dataAdapter, altrows: true, selectionMode: 'none', enableHover: false, ready: function () { // Expand rows with ID = 1, 2 and 7 $("#treeGrid").jqxTreeGrid('expandRow', 1); $("#treeGrid").jqxTreeGrid('expandRow', 2); $("#treeGrid").jqxTreeGrid('expandRow', 7); }, editable: true, columns: [ { text: 'ID', dataField: 'id', width: 100 }, { text: 'Name', dataField: 'name', width: 220 }, { text: 'Budget', align: 'right', cellClassName: cellClass, cellsAlign: 'right', cellsFormat: 'c2', dataField: 'budget', width: 200 }, { text: 'Location', dataField: 'location' } ] }); $("#excelExport").jqxButton(); $("#excelExport").click(function () { $("#treeGrid").jqxTreeGrid('exportData', 'xls'); }); }); </script> </head> <body class='default'> <style> .max { color: black\9; background-color: #63be7b\9; } .avg { color: black\9; background-color: #f8e984\9; } .minavg { color: black\9; background-color: #f9806f\9; } .min { color: black\9; background-color: #f8696b\9; } .max:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .max:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) { color: black; background-color: #63be7b; } .avg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .avg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) { color: black; background-color: #f8e984; } .minavg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .minavg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) { color: black; background-color: #f9806f; } .min:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .min:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) { color: black; background-color: #f8696b; } </style> <div id="treeGrid"> </div> <div style='margin-top: 20px;'> <div style='float: left;'> <input type="button" value="Export to Excel" id='excelExport' /> <br /> <br /> <input type="button" value="Export to XML" id='xmlExport' /> </div> <div style='margin-left: 10px; float: left;'> <input type="button" value="Export to CSV" id='csvExport' /> <br /> <br /> <input type="button" value="Export to TSV" id='tsvExport' /> </div> <div style='margin-left: 10px; float: left;'> <input type="button" value="Export to HTML" id='htmlExport' /> <br /> <br /> <input type="button" value="Export to JSON" id='jsonExport' /> </div> </body> </html>
Hi simcon94,
The solution is to write: var cellValue = cellText instead of var cellValue = rowData[dataField];
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.