jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Zero Aggregates
Tagged: aggregates, aggregatesrenderer, custom, grid, jqxgrid
This topic contains 4 replies, has 2 voices, and was last updated by Dimitar 11 years, 6 months ago.
-
AuthorZero Aggregates Posts
-
Hello,
I have a question regarding aggregatesrenderer. I followed the sample on the site. When I simply use aggregates they show up fine within the grid. However, when I add the aggregatesrenderer (as seen below) I only get a blank cell. When I put a breakpoint (and display) in my code the aggregates param is en empty object -i.e. Object{} – i.e. no aggregates, thus I do not get any values showing up. Any assitance would be be appreciated. Thanks!{ text: 'Status', datafield: 'status', cellclassname: cellclass, cellsformat: 'c2', width: 100, aggregates: [ { 'Pending': function (aggregatedValue, currentValue) { if (currentValue == "Pending") { return aggregatedValue + 1; } return aggregatedValue; } }, { 'Processed': function (aggregatedValue, currentValue) { if (currentValue == "Processed") { return aggregatedValue + 1; } return aggregatedValue; } }, { 'Rejected': function (aggregatedValue, currentValue) { if (currentValue == "Rejected") { return aggregatedValue + 1; } return aggregatedValue; } } ], aggregatesrenderer: function (aggregates, column, element) { var renderstring = "<div class='jqx-widget-content jqx-widget-content-" + theme + "' style='float: left; width: 100%; height: 100%;'>"; console.log(aggregates); $.each(aggregates, function (key, value) { console.log('key = ' + key + 'value = ' + value); if (isPending(value)) { theclass = 'orange'; } else if (isRejected(value)) { theclass = 'red'; } else if (isProcessed(value)) { theclass = 'green'; } else if (isCancelled(value)) { theclass = 'brown'; } else theclass = 'black'; renderstring += '<div class="' + theclass + '">' + key + ': ' + value + '</div>'; }); renderstring += "</div>"; cl(renderstring); return renderstring; } }
Quick follow-up – my grid definition looks like this:
$("#jqxgrid").jqxGrid( { width: aWidth, altrows: true, source: dataAdapter, theme: theme, showstatusbar: true, statusbarheight: 60, enabletooltips: true, sortable: true, columnsresize: true, columnsreorder: true, columnsmenu: true, showaggregates: true, columns: [ ........
Hello robf,
Everything seems fine in your code. Here is a suggestion you may try out, hower – put all custom aggregates in a single object, as shown:
{ 'Pending': function (aggregatedValue, currentValue) { if (currentValue == "Pending") { return aggregatedValue + 1; } return aggregatedValue; }, 'Processed': function (aggregatedValue, currentValue) { if (currentValue == "Processed") { return aggregatedValue + 1; } return aggregatedValue; }, 'Rejected': function (aggregatedValue, currentValue) { if (currentValue == "Rejected") { return aggregatedValue + 1; } return aggregatedValue; } }
Please also make sure you are using the latest version of jQWidgets (3.0.4).
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hello Dimitar,
Thanks for your prompt response, however the suggestion above did not work. I also tried using the latest version (3.0.4) with the same results. Really not sure what the issue could be. I’ve attached a before/after for reference. Thank you, kindly.
Robert
Hi robf,
Please provide us with a complete code example, including sample data, which we may test locally.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.