Categories | Question details Back To List | ||||||||
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 Answer posted by Support on Mar 27, 2008 07:30 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 ) Answer posted by Nasir on Mar 27, 2008 08:23 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 Answer posted by Support on Mar 27, 2008 09:30 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. Attachments (1)
Answer posted by claude-michaud@bluewin.ch on Mar 31, 2008 15:26 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 Answer posted by Support on Apr 01, 2008 10:18 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); } Answer posted by Claude Michaud on Apr 09, 2008 13:31 Thanks, it works fine. In a next build, it would be fine to setup a property to control that mode. Best regards Answer posted by Support on Apr 10, 2008 01:55 We will add it to our TODO list. Answer posted by Nasir on May 08, 2008 05:57 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 Answer posted on May 15, 2008 01:31 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 Answer posted by Support on May 15, 2008 05:05 >>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. Answer posted by Support on May 15, 2008 05:17 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"); } |