PDA

View Full Version : help needed: check duplicates in photo organizer



Spirit
3 Sep 2007, 3:45 AM
Thought this must be an easy task, but i m not able to solve it.
In the example is a function
ImageDragZone -> getTreeNode

In this function data is prepared to be added to the tree. It would be easy to sort out duplicates here but i have no reference to the tree node on which the picture is droped :((

Next I tried get the information from the dropzone, also without success, but i think there could be a start point ?!

I dont know where to start exactly or which functions to override :(
If someone could give me a hint or a code example i would be very thankfull :)

Spirit
9 Sep 2007, 8:09 PM
No one ?

Animal
9 Sep 2007, 11:23 PM
You need to add a check in the GetTreeNode function.

You have




treeNodes.push(new Ext.tree.TreeNode({
text: data.name,
icon: data.url,
data: data,
leaf:true,
cls: 'image-node',
qtip: data.qtip
}));


You see it creating a new node. You want to check whether there is nother node with an icon value the same as data.url?

Get the TreePanel's root node, and use

http://extjs.com/deploy/ext/docs/output/Ext.tree.TreeNode.html#findChildBy

Return false if a duplicate is found.

Spirit
10 Sep 2007, 9:53 PM
thx 4 your reply animal.

I agree with your suggestion, thats how i would do it and how i tried.
But my problem is that in the function you mentioned (getTreeNode ...) i cant figure out on which child the new picture is droped.
Lets say our tree root is "albums" and there are 3 childs : "album1", "album2" and "album3"
i changed the code so i know my root "albums" in the above function but i dont know on which child the the new picture was droped.
I can look through all childs and find a picture which is similar to the one which was droped, but may be the picture is in "album1" and it should also be in "album2". So i could prevent duplicates across all 3 albums.
I only want a user to prevent him from putting the same picture twice in the same child (album).
But i m unable to figure out on which of the childs the new picture was droped.

am i missing something ?