Can't access global variable from inside startRender() function
Can't access global variable from inside startRender() function

Hello!
I am having a problem with accessing global variables inside my rowGroup().startRender() function. I couldn't find any post in forum that has came across this problem.
My code:
<script>
$(document).ready(function(){
var sum = {};
var groupColumn = 'columnName2';
rowGroup: {
startRender: function(rows, group, level) {
if (!(group in sum)) {
sum[group] = rows
.rows({ search: 'applied' })
.data()
.filter(function (value, index) {
return (value[groupColumn] == group) ? true : false;
})
.pluck('columnName')
.reduce(function (a, b) {
return a + b * 1;
}, 0);
}
}
}
})
</script>
In this example, function recognizes groupColumn variable which I have declared but dictionary (sum) is undefined.
Thanks in advance!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Seems to work here:
http://live.datatables.net/dafefime/2/edit
Please provide a test case or update mine to show the problem.
Kevin
Sorry, my mistake.
I initialized variable with the same name afterwards in the code. That's why it was undefined.
Appreciate the help!