I've got a treeview with checkable nodes. I'm trying to keep a count of how many are checked and I'm using the OnClientNodeChecking call to do so. Here is my function:
However, I noticed when I click the checkbox quickly, the event does not get called and therefore the counts are incorrect. Here is a video displaying the issue.
http://screencast.com/t/1FkFLNDk6
You'll notice when the screen first loads, the count is correct. If I click the checkbox, the count changes correctly. But if I double-click a checkbox, the count is not longer in sync. When the box is checked, it shows 4, when it's unchecked it shows 5, but it should be the other way around. I've also noticed that when I do a postback and check the state of the node in the code behind, it does not reflect what is being on the screen. Basically, the number that you see next to the parent node correctly corresponds to the number of nodes the treeview believes are checked when it gets to the code behind. However, what is displayed does not match with what the treeview actually thinks is checked.
Hopefully that makes sense,
Adam
function
UpdateTotal(sender, eventArgs) {
var
node = eventArgs.get_node();
var
pnode = node.get_parent();
var
attribs = pnode.get_attributes();
var
cnt = attribs.getAttribute(
"Count"
);
if
(!node.get_checked()) {
cnt++;
}
else
{
cnt--;
}
attribs.setAttribute(
"Count"
, cnt);
// var cnodes = pnode.get_nodes();
// var cnt = 0;
// for (var i = 0; i < cnodes.get_count(); i++) {
// if (cnodes.getNode(i).get_checked()) {
// cnt++;
// }
// }
pnode.set_text(attribs.getAttribute(
"DefaultName"
) +
' ('
+ cnt +
')'
);
}
However, I noticed when I click the checkbox quickly, the event does not get called and therefore the counts are incorrect. Here is a video displaying the issue.
http://screencast.com/t/1FkFLNDk6
You'll notice when the screen first loads, the count is correct. If I click the checkbox, the count changes correctly. But if I double-click a checkbox, the count is not longer in sync. When the box is checked, it shows 4, when it's unchecked it shows 5, but it should be the other way around. I've also noticed that when I do a postback and check the state of the node in the code behind, it does not reflect what is being on the screen. Basically, the number that you see next to the parent node correctly corresponds to the number of nodes the treeview believes are checked when it gets to the code behind. However, what is displayed does not match with what the treeview actually thinks is checked.
Hopefully that makes sense,
Adam