jQuery UI Widgets › Forums › Grid › Avoid to render aggregate to particular column
Tagged: aggregates, aggregatesrenderer, dynamics columns, grid
This topic contains 1 reply, has 2 voices, and was last updated by Hristo 7 years, 3 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
Hi,
I am binding dynamic column to grid with aggregates.I dont want to display aggregate to first column instead i just wanted to display “total” label in first column.var source = { localdata: myObject, datatype: "json" }; var datafields = new Array(); var columns = new Array(); for (var i in myObject[0]) { datafields.push({ name: i }); columns.push({ text: i, datafield: i, aggregates: [{ 'Total': function (aggregatedValue, currentValue, column, record) { var total = aggregatedValue + parseInt(record[column]); return total; }}], aggregatesrenderer: function(aggregates) { var renderstring = aggregates["Total"]; return '<span style="margin-top: 4px;">' + renderstring + '</span>'; } }); } var source = { datatype: "json", datafields: datafields, localdata: myObject }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgridDist").jqxGrid( { width: 700, height: 400, source: dataAdapter, sortable: true, pageable: true, autoheight: true, columnsresize: true, filterable: true, showfilterrow: true, showaggregates: true, showtoolbar: true, showstatusbar: true, rendertoolbar: function (toolbar) { var container = $("<div style='overflow: hidden; position: relative; margin: 3px;'></div>"); var exportButton1 = $("<div id='exportexcel1' style='float: right; margin-right: 5px;'> <img src='./images/excel.png' /><span style='margin-left: 4px; position: relative; top: -3px;'>Export to Excel</span></div>"); container.append(exportButton1); toolbar.append(container); exportButton1.jqxButton({ width: 150, height: 20 }); exportButton1.click(function () { data = myObject; if (data == '') return; if (data == myObject) { JSONToCSVConvertor(data, "Crop Analysis", true); data = ''; return data; } }); }, columns: columns });
Hello veenahosur,
I would like to suggest you to add conditional statement there (
if (i == 1) { /*Add logic for the first column*/ }
).
You could set different settings for different columns in that way.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.