Search by separate words

Hello,

We are using dhtmlxCombo for dynamic searching the items. It shows the suggested items which start from the letters, that are entered into the search field.

Is it possible to use dhtmlxCombo to search by separate words?

Like:
Item “John Bell” should appear in the suggested items list when you type “Be”.

Thank you

Hello,

it is possible to enable search from any position by code modification - in dhtmlxcombo.js you need to locate:

var filter=new RegExp("^"+text,“i”); } catch (e){ var filter=new RegExp("^"+text.replace(/([[]{}()+*\])/g,"\$1"));

and replace with

var filter=new RegExp(text,“i”); } catch (e){ var filter=new RegExp(text.replace(/([[]{}()+*\])/g,"\$1"));

Thank you so much! It’s working great!

Would it be possible to only filter on EXACT matches?

Would it be possible to only filter on EXACT matches?

You may modify the dhtmlxcombo.js, replace the following line

var z = filter.test(this.optionsArr[i].content?this.optionsArr[i].data()[1]:this.optionsArr[i].text);

with

var z = (this.optionsArr[i].content?this.optionsArr[i].data()[1]==text:this.optionsArr[i].text==text);

I tried this suggestion of replacing this
var filter=new RegExp("^"+text,“i”); } catch (e){ var filter=new RegExp("^"+text.replace(/([[]{}()+*\])/g,"\$1"));

with

var filter=new RegExp(text,“i”); } catch (e){ var filter=new RegExp(text.replace(/([[]{}()+*\])/g,"\$1"));

But now the combo box is not giving the expected behavior. Whatever I type in the combo box the first letter is being typed as ‘A’ or some other letters. Rest of the letters are typed correctly. If go and delete a the search is working correctly. I am attaching my dhtmlxcombo.js file for reference.

For testing please check the below url
125.17.102.10/demo/consultation_new1.aspx

I have a combo with some symptoms. When I type “Dim” in the combo it inputs “EYM” in the combo. I am trying to search the word “Diminision of vision”. The basic search functionality is not working correctly now.
Please check if something is wrong with my dhtmlxcombo.js file.
dhtmlxcombo.zip (7.04 KB)

You may increase the filtering timeout. In the dhtmlxcombo.js

window.setTimeout(function(){ that._onKeyB(ev); },1);

try to change it:

window.setTimeout(function(){ that._onKeyB(ev); },1000);

Hi Alexandra ,

I have followed your suggestion and increased the filtering timeout to 1000. But even now the behavior is not as expected. Try the same URL I sent you yesterday.
When I enter the word “Eye” in the combo box it should display all the words containing or starting with “Eye” instead it is just displaying the first match and autocompleting as “Black Eye”. Please suggest how to solve this.

Thank You,
Sravanthi

Hi,

Try one more modification in the dhtmlxcombo.js, filterSelf method:

locate

if (!mode) this._correctSelection(); else this.unSelectOption();

and replace with:

this.unSelectOption();

(remove or comment if (!mode)this._correctSelection(); else )

In this case you don’t need modification with Timeout I provided in the previous answer.

Hi Alexandra ,

Thanks a lot. This solved the problem.

Regards,
Sravanthi