dhtmlxcombo filter a part of the string

Hi,



I’m using the dhtmlxcombo and want to filter not only the first part of the string but also at the middle part etc…



so when i have the following string in my combo list:



Royal Haskoning



and i only remmember “haskoning”, then it will never lead to the right result. Is it possible to search at a part of the string and highlight the searched string in all combination in the list red?



the reason is that i’m currently using an othe combobox which offers me this functionality. However, it is not cross browser compatible. the combobox i’m currently using uses the following script.



function formatCountries( sText )

{

return sText.substr( 0, sText.toLowerCase().indexOf( this.sActiveValue.toLowerCase() ) ) + sText.substr( sText.toLowerCase().indexOf( this.sActiveValue.toLowerCase() ), this.sActiveValue.length ).bold().fontcolor( ‘#ff0000’ ) + sText.substr( sText.toLowerCase().indexOf( this.sActiveValue.toLowerCase() ) + this.sActiveValue.length )

}

function alertSelected()

{

document.getElementById( ‘klanten’ ).innerHTML = this.sActiveValue;

}





is it possible to due the same with dhtmlxcombo?



regards,

Nasir

It possible to adjust the way how search mask works

dhtmlxcombo.js , line 953
    try{ var filter=new RegExp("^"+text,“i”); } catch (e){ var filter=new RegExp("^"+text.replace(
can be updated as
    try{ var filter=new RegExp(text,“i”); } catch (e){ var filter=new RegExp(text.replace(

in result, combo will search text rows which has any occurrence of typed substring.

>>and highlight the searched string in all combination in the list red
There is no such functionality in current version of combo ( it sounds as good addition, so we try to include it in one of next versions )


Hi,



i made the adjustment however it did not have any effect.



ps: in my file it is line 910 and not 953 like you sujusted, perhaps it has something to do with that?



Nabeel

Please check attached sample

>>ps: in my file it is line 910 and not 953 like you sujusted, perhaps it has something to do with that?
Line position may differ, based on build version, but the changes are the save for all builds.

1206636226.zip (15.5 KB)


Hello,



I just tested your solution and it works quite fine, although it remains a small problem.



In your sample, try to digit “me”, as a part of some. As xou type the “m”, the combo find “some a00” and highliht-it and also copy it to the text box.



The result is that when you type the “e”, the combo will search “se” and not “me”.



I suppose it would work fine if, in that case, we could disable the highlighting.



Is that possile?



Best regards,



Claude Michaud

To disable autocomplete - you can locate and remove next lines in dhtmlxcombo.js

lines 849-852
            if (text!=data[1]){
               this.setComboText(data[1]);
               dhtmlXRange(this.DOMelem_input,text.length+1,data[1].length);
            }


Thanks, it works fine.



In a next build, it would be fine to setup a property to control that mode.



Best regards

We will add it to our TODO list.


Hi,



i would like to know whether its possible to use 2 dhtmlxcombo’s. One with basis autocomplete function and one where you can search only a part of the string.



if so please tell me how to achieve that?



 



kind regards,



Nasir


Hi,



I have still heard nothing so far about my question. Perhaps you guys have been bissy but could you be so kind enough to reply whether its possible to use 2 dhtmlxcombo’s. One with basis autocomplete function and one where you can search only a part of the string.



Nasir


>>where you can search only a part of the string



You can have multiple comboboxes on the page in different modes, there is no any restrictions.
But filtering mode of combo box filter options which started from entered text, you can’t filter by substring


It possible to update code of dhtmlxcombo, so it will filter by any substring occurence, but it will change logic for all instances of dhtmlxcombo, not only desired one.



dhtmlxcombo.js , line 955



 try{ var filter=new RegExp("^"+text,“i”); }



this line define RegExp used to filtering, just update it as



 try{ var filter=new RegExp(text,“i”); }