jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Suggestion : change aggregate's function count
This topic contains 11 replies, has 4 voices, and was last updated by rharding98 10 years, 7 months ago.
-
Author
-
When we use the aggregate’s function count, it does count every row, even those with null value.
We can use this aggregate on any column, it will return the same result : the number of rows.
Because the aggregate’s functions are use on specific column, it would make more sense to count only rows with values. This way, the count function would return a different value for every column, instead of just counting the number of rows.
I know that it’s not hard to create a custom aggregate function (I did mine). But I feel that the current count function is not logical in the context where it is use now.
Regards
And is there a way to overwrite an aggregate function? Let’s say I want to redefine “count” or “avegage”?
I think count is a count, and null values must be included in count as well. If you do not want them to appear, filter the data.
You can write your own aggregate function. As a start, take a look demos/jqxgrid/customaggregates.htm
Thank you. I already know how to create a custom aggregate, but it would be much more convenient if I could overwrite standard function, something like “$.jqxGrid.aggregate.count = function(…){…}”.
I would also like to point out that the average function is broken. If you do the average of a column with null values, every null values is treated like it was a 0. It doesn’t make sense, because a null value isn’t 0, it is just null.
Regards
Hi Nicolas,
Average takes into account all rows, too and yes, null is equal to 0 in the function’s calculation.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/I think that there is also a problem with the min function. If I ask the min of [null, null, 6], the footer is null. I didn’t try what happen if I have a value less than 0. Max returns me 6 on this example. I really think that there is a problem with our functions when they are handling null values. On my side, I won’t be able to use it because of that.
I think there should at least be an option to have the aggregate functions ignore null. Null does not equal Zero.
Was an option to ignore null ever added?
Hi rharding98,
You can implement custom aggregates using custom aggregation functions.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Yeah but could you explain why this fiddle is ignoring the null on the price aggregates without a custom aggregation function?
Thanks,
RoyHi Roy,
The built in aggregates work as they are designed. If you need custom functions, you can create custom aggregates.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/I’m not asking for anything custom I just don’t want null to be considered a zero in the built in aggregate. The jsfiddle I linked is ignoring the null which is what I want it to do. 🙂
-
AuthorPosts
You must be logged in to reply to this topic.