jQuery UI Widgets › Forums › Grid › Export data with cellsrenderer value.
Tagged: cellsrenderer, Exportdata, jqxGrid ;
This topic contains 7 replies, has 5 voices, and was last updated by admin 3 weeks, 3 days ago.
-
Author
-
hi,
I have a jqxgrid with cellsrenderer for total column. Everything working fine.
Now I want to export data to a local variavle as JSON string. Here comes the problem, If try $(“#jqxgrid”).jqxGrid(‘exportdata’, ‘json’); the total column comes with “”(empty) value.any other way to achieve this or any clue please.
Hi vinothr,
Exporting result of “cellsrenderer” callback function is not possible, because “cellsrenderer” returns HTML, not Text.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comhi peter,
but i require those values. is there any other way to do this.
Vinoth R
Hi vinothr,
The exportdata method accepts an Array of Rows as parameter so you can pass what kind of data would be exported. My suggestion is: Get the Grid’s rows by using the “getrows” method. Make the necessary customizations in that array in order to fit to your requirements and pass it to the “exportdata” method call in the way pointed out in the Grid’s API Docs.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I write this code as you mentioned. But the result is same. Column value is different that I want.
What part did I mistake?$btnExcel.click(function () { var gridRows = $jqxGrid.jqxGrid('getrows'); $jqxGrid.jqxGrid('exportdata', 'xls', 'Magam', true, gridRows, false, null, 'utf-8'); });Ah now I understand your intend. I solve problem like this.
I test on your ‘getrows’ jsfiddle source.
Change javascript code.var data = generatedata(5); var source = { localdata: data, datafields: [{ name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'date', type: 'date' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' }], datatype: "array" }; var cellsrenderer_MS = function(row, column, value, defaulthtml, columnproperties) { var rowData = $("#jqxgrid").jqxGrid('getrowdata', row); return '<div class="cellren_height">' + rowData.firstname + ' / ' + rowData.lastname + '</div>'; } var adapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid({ width: 500, height: 100, theme: 'energyblue', source: adapter, sortable: true, selectionmode: 'singlecell', columns: [{ text: 'First Name', datafield: 'firstname', columngroup: 'Name', width: 90, cellsrenderer: cellsrenderer_MS }, { text: 'Last Name', columngroup: 'Name', datafield: 'lastname', width: 90 }, { text: 'Product', datafield: 'productname', width: 170 }, { text: 'Order Date', datafield: 'date', width: 160, cellsformat: 'dd-MMMM-yyyy' }, { text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'right' }, { text: 'Unit Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2' }] }); $("#jqxbutton").jqxButton({ theme: 'energyblue', width: 200, height: 30 }); $('#jqxbutton').click(function() { var rows = $('#jqxgrid').jqxGrid('getrows'); rows[0].firstname = rows[0].firstname + ' / ' + rows[0].lastname; $('#jqxgrid').jqxGrid('exportdata', 'xls', '마감', true, rows, false, null, "euc-kr"); });Then you can export rendered data.
I have tried the above code and still cannot get it to export the cellsrenderer.
Here is my code:
`var summaryData = $ (“#roomOrgCountTable”).jqxGrid (‘getcolumnaggregateddata’, ‘OrganizationCount’, [‘sum’]);
console.log (summaryData)var totalSum = summaryData.sum;
console.log (totalSum)var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties, rowdata)
{
var total = parseFloat (rowdata.OrganizationCount);
var percentage = (total / totalSum) * 100;
return ‘<span style=”margin: 1px; float: right;”>’ + percentage.toFixed(2) + ‘%</span>’;
};$ (“#roomOrgCountTableB”).jqxGrid (
{
width: ‘100%’,
height: 300,
theme: ‘summer’,
source: dataAdapter,
enablebrowserselection: true,
pagermode: “simple”,
pageable: false,
rowDetails: true,
columnsResize: false,
columnsreorder: false,
altRows: true,
sortable: true,
filterable: true,
showfilterbar: true,
showstatusbar: true,
showaggregates: true,
statusbarheight: 25,
localization: {thousandsSeparator: “,”},
columns: [{text: ‘Building Name’, dataField: ‘LONGNAME’, width: 220, align: ‘left’, aggregates: [“count”]},
{text: ‘Organization’, dataField: ‘ORGANIZATION’, width: 250, align: ‘left’},
{text: ‘Rooms’, dataField: ‘OrganizationCount’, width: 70, align: ‘left’, aggregates: [“sum”]},
{text: ‘Net Area’, dataField: ‘NetArea’, width: 80, align: ‘left’, cellsFormat: ‘d0’, aggregates: [“sum”]},
{text: ‘Rooms %’, cellsFormat: ‘d2’,width: 80, cellsrenderer:cellsrenderer}
]
});$ (“#csvExportOrgStats”).on (‘click’, function ()
{$ (“#roomOrgCountTableB”).jqxGrid (‘exportData’, ‘xls’, getOrgBuildingName + ‘_Stats_’ + todaysDate, true, null, true, ‘https://uwoperations.uwyo.edu/uwopsmaps/JQueryExport/dataexport.php’);
});
Any help would be appreciated.
Hi,
Export of cellsrenderer data is not supported because it returns html which we cannot render in excel.
Regards,
Peter -
AuthorPosts
You must be logged in to reply to this topic.