Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by aalekhya on Mar 04, 2009 05:24
open dhtmlx forum
Issue with tree

Hi
Iam using dhtmTree in my code.
I used Find functionality in tree.
I know tree support only text search.But i want special characters search.
For that i changed code in dhtmltree.js as below
dhtmlXTreeObject.prototype._findNodeByLabel=function(searchStr,direction,fromNode){
searchStr = new RegExp(searchStr.replace(/([\*\^\$\&\?\<\;\:\>\|\+\\\[\]\(\)]{1})/gi,"\\$1").replace(/ /gi,".*"),"gi");

but it is not working for some special characters.For that i wrote code in my userdefined javascript file as
searchString=searchString.replace('&','&');
searchString=searchString.replace('<','<');
searchString=searchString.replace('>','>');
searchString=searchString.replace('"','"');

But still it is not working for (;," ') for these charactes.
Please provide me solution for that.Can u please send me the code how to add all the special characters for search critieria.

I want to search all the characters like
~!@#$%^&*()_+=-`":;'|\><?/.,

Please provide me soltuion.
Because iam unable to solve the issue.
Its very urgent to me.
Please provide me solution
Answer posted by Alex (support) on Mar 04, 2009 07:48

Hi,

You can try to use the following code modificaton:

dhtmlXTreeObject.prototype._findNodeByLabel=function(searchStr,direction,fromNode){
  //trim
  var searchStr=searchStr.replace(new RegExp("^( )+"),"").replace(new RegExp("( )+$"),"");
  searchStr = searchStr.replace(/([\*\^\$\?\;\:\|\+\\\[\]\(\)\!\.]{1})/gi,"\\$1").replace(/ /gi,".*");
  searchStr = searchStr.replace(/&/gi,"(&amp;|&)").replace(/</gi,"(&lt;|<)").replace(/>/gi,"(&gt;|>)");
  searchStr = new RegExp(searchStr,"gi");

..

The sample is sent by email. 



Answer posted by aalekhya on Mar 04, 2009 08:31

Hi

I used the function what u gave to me.

But still the special characters ;' "  are not working

And ~ CHARACTER is not shown if it is in subnode befoe expanding node.

After expanding it is working.

Why this is happened?

Is there any browser issue or can i change any code in Common.js?

Please help me

Thanks

aalekhya

 

Answer posted by Alex (support) on Mar 04, 2009 08:54

Hi,

Is the issue reproduced at the sample we have sent you today ?

Locally all item are found correctly .

Answer posted by aalekhya on Mar 05, 2009 05:40

Hi

The sample code is working fine.My code is also working fine.

A small problem in the sample.

If i search a character it searched from top to bottom.After it reached to bottom if i click find button it goes to top of the tree.

but for my code i have to give an alert message after reached to bottom of the tree,it should display "NO Additonal Occurences".

So i want to stop the searching once it comes to bottom.

If i enter another text in the text box after the alert message then searching should start from top of the tree.

Can u provide me code for that functionality.

Thanks

aalekhya

Answer posted by Alex (support) on Mar 05, 2009 07:06

Hi,

findItem methods returns an id if an item is found and null - in the other case.

So, you check if the item is already found. If it is, the previous item can be selected and message shown.