Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stefan Riedel-Seifert on Jan 26, 2009 02:04
open dhtmlx forum
Tree: Search & Editable Items

Hello,

i faced out the following problem:

if i have a tree with editable item and a search field for tree search (as like in the samples), the tree shows the following
behavour:

1) Searching for the first time: the tree finds the item and opens the right node. All fine.
2) Pressing the search button again (stupid users does such things): the tree interprets this, that the item will be edited

I have used the onEditHandler to investigate, if the user can edit the item or not. Not all items should be editable. In this case
i bring up an error popup. Now the error popup comes, if the user presses the search button twice.

Best regards
Stefan
Answer posted by Support on Jan 26, 2009 02:44
Which method you are using for item searching?

Tree has two methods - findItem and findItemIdByLabel
first one selects found item and fire onClick event for it, which will cause switching to edit mode if "single-click edit" enabled

Second possible scenario, if user uses enter key for search button pressing, after first pressing focus will be moved in tree and if keyboard-navigation enabled for the tree it will threat second enter key pressing as "call" command for the item in tree, which will call onClick event in tree as in first scenario.

You can disable edit start from single click by using
       tree.setEditStartAction(false,true);
Answer posted by Stefan Riedel-Seifert on Jan 26, 2009 02:53

Hi,

 

i know both methods, but i don't know why, the method findItemIdByLabel doesn't find any items. It seems, that it doesn't react. The mothod findItem instead does find my items.

 

:-(?

 

Best regards,
Stefan

Answer posted by Support on Jan 26, 2009 05:46
The findItemIdByLabel return Id of item, but not mark it in tree. 
The common use-case is the next

var id = tree.findItemIdByLabel(some);
if (id) {
       tree.selectItem(id,false); //select without call
       tree.focusItem(id); //adjust scroll to make item visible
}
Answer posted by Stefan Riedel-Seifert on Jan 26, 2009 06:03

Hi,

it works :-) Thank you very much! In addition, i need only one Search button (no search next).

 

Best regards,

Stefan