Hi, I wrote a subtotal for Grid groups. I try to keep the row at the bottom of each group. My issue is that whenever a user filters it needs to be recomputed and when its sorted it gets moved. So I made 2 functions 1 that removes the subtotals, by id, and another that adds subtotals, which does the computation.
I then,
<code>grid.attachEvent(
"onAfterSorting",
function(index,type,direction){
removeSubtotalsToGroups();
addSubtotalsToGroups();
}
);
grid.attachEvent(
"onFilterEnd",
function(elements){
removeSubtotalsToGroups();
addSubtotalsToGroups();
}
);</code>
I put alerts in those callbacks and they get called when I do sortings or filters but the rows are put into the wrong locations.
If I do this (some repeated) in a callback for onXLE:
grid.attachEvent(
“onBeforeSorting”,
function (ind,type,direction){
removeSubtotalsToGroups();
addSubtotalsToGroups();
return true;
}
);
grid.attachEvent(
“onAfterSorting”,
function(index,type,direction){
removeSubtotalsToGroups();
addSubtotalsToGroups();
}
);
grid.attachEvent(
“onFilterStart”,
function(indexes,values) {
removeSubtotalsToGroups();
addSubtotalsToGroups();
return true;
}
);
grid.attachEvent(
“onFilterEnd”,
function(elements){
removeSubtotalsToGroups();
addSubtotalsToGroups();
}
);
It works only if I add these 4 extra remove/adds. I put alerts into all of them and see them being called many times. I don’t know if their events are messed up or if maybe groupby calls sorting or filter and the docs don’t say. Does anyone know why it seems like onFilterEnd and onAfterSorting don’t seem like they are really at the end of filtering and the end of sorting?
Oh the reason I’m asking about this is because this is making the js really slow. If it only ran once for each action the user did it would be fine. I almost need a dirty flag that gets set whenever the user hits the sort or filter or refresh functions, maybe.
My main question I guess is how can I just remove and add subtotals when the user does something to the groups?