PDA

View Full Version : to get unchecked treenodes



pailyanish
31 Oct 2009, 12:03 AM
hai,

i am new to extjs

i have a treepanel with treenodes with checkboxes

i get number of checknodes by .getChecked method

is there any method to get unchecked nodes.


thanks in advance

DeDarling
4 Nov 2010, 6:07 AM
Push .. this is a question i actually have ...

Please help ..

i tried ...



tree.root.childNodes.eachChild(function(child){
if (child.getUI().isChecked()) {
//sql = child.parentNode.text;
}
});

Condor
4 Nov 2010, 6:21 AM
So you want:

var checked = [];
tree.getRootNode().eachChild(function(child){
if (!child.getUI().isChecked()) {
checked.push(child.text);
}
});
Or were you looking for the cascade() function instead of eachChild()?

notjoshing
4 Nov 2010, 6:34 AM
I've used the same approach as Condor shows here. If you're looking to do something to all the nodes, then cascade works better. What is it specifically that you need to do?

DeDarling
4 Nov 2010, 6:42 AM
Hmm i am want to build an SQL String from the "de"-selected Nodes in my Tree...

Bsp:

+Merkmale
|-+Merkmal1 /selected
|--+Merkmal1.1
|--+Merkmal1.2 /selected
|--+Merkmal1.3
|-+Merkmal2 /selected
|--+Merkmal2.1 /selected
|--+Merkmal2.1

and now i must build the sql like:

"where Merkmal1 in ('Merkmal1.2') AND Merkmal2 in ('Merkmal2.1)"

Condor
4 Nov 2010, 6:45 AM
OK, but a browser can't execute SQL. You need to send something to the server (a list of ids of unchecked nodes?) so the server can build the SQL string.

DeDarling
4 Nov 2010, 6:48 AM
Yes yes ... i know :-)

i use ext js only to build the sql string .... :-) look 1 post above ...

Condor
4 Nov 2010, 7:05 AM
var sql = [];
tree.getRootNode().eachChild(function(node){
var checked = [];
node.eachChild(function(node2){
if (node2.getUI().isChecked){
checked.push(node2.text);
}
});
sql.push(node.text + ' in (\'' + checked.join('\',\'') + '\')');
});
sql = 'where ' + sql.join(' and ');
Disclaimer: Completely untested code!

ps. I think it's a security risk that you are building SQL on the client!

DeDarling
4 Nov 2010, 7:09 AM
Thy man youre great i will test ist .:-)

Yes i know about the risk but its only for Intranet User ...

DeDarling
4 Nov 2010, 7:15 AM
Oh man im so an ***** ... sry ... i explained it wrong .. but your Script work fine :-)

+Merkmale
|-+Merkmal1 /selected
|--+Merkmal1.1 /selected
|--+Merkmal1.2 /[deselected]
|--+Merkmal1.3 /selected
|-+Merkmal2 /selected
|--+Merkmal2.1 /[deselected]
|--+Merkmal2.1 /selected
|-+Merkmal3 /selected
|--+Merkmal2.1 /selected
|--+Merkmal2.2 /selected
|--+Merkmal2.3 /selected

So an now :-)

"where Merkmal1 in ('Merkmal1.2') AND Merkmal2 in ('Merkmal2.1)"

Its an "negative" List Tree ..

sorry 4 my "dummheit" ...

Condor
4 Nov 2010, 7:45 AM
var sql = [];
tree.getRootNode().eachChild(function(node){
var checked = [];
node.eachChild(function(node2){
if (!node2.getUI().isChecked()){
checked.push(node2.text);
}
});
if (checked.length) {
sql.push(node.text + ' in (\'' + checked.join('\',\'') + '\')');
}
});
sql = 'where ' + sql.join(' and ');

DeDarling
4 Nov 2010, 11:12 PM
Hi,

used your code with one little change....


var sql = [];
tree.getRootNode().eachChild(function(node){
var checked = [];
node.eachChild(function(node2){
//if (!node2.getUI().isChecked){ <--- this dont work 4 me ...
if (node2.attributes.checked == false){ <--- this works ... any idea ?
checked.push(node2.text);
}
});
if (checked.length) {
sql.push(node.text + ' in (\'' + checked.join('\',\'') + '\')');
}
});
sql = 'where ' + sql.join(' and ');


BIG THX TO YOU :-) Is there a function here to rate the Support Members ? I give you an 1+ :D

Condor
5 Nov 2010, 12:11 AM
node2.getUI().isChecked doesn't work, because it should have been node2.getUI().isChecked().

ps. There is no rating system, but you can add to a posters reputation (click on the star on the left lower side of the post).

DeDarling
5 Nov 2010, 12:19 AM
node2.getUI().isChecked doesn't work, because it should have been node2.getUI().isChecked().

ps. There is no rating system, but you can add to a posters reputation (click on the star on the left lower side of the post).

Ok :-) Done -.. Thx .