Issues with dhtmlxCombo control in filtering mode

We are facing a problem with dhtmlxCombo control while filtering the options available in the list.

We are using

  1.  Standard Edition of dhtmlxCombo v 2.6. downloaded from link [dhtmlx.com/x/download/regula ... xCombo.zip](http://www.dhtmlx.com/x/download/regular/100722/dhtmlxCombo.zip).
    
  2.  enableFilteringMode() method of dhtmlxCombo object by passing single parameter as "true".
    

Ex : var z=dhtmlXComboFromSelect("html_select_control_id ");

    z.enableFilteringMode(true);

Expected output : When user enters any number of characters in combobox then it should filter all the options containing entered character string.

Actual output : When user enters any number of characters in combobox it is filtering only those options starting with entered character string.

Is this known issue on autocomplete combobox ? Any pointers?
Is this resolved in Enterprize edition ?

This is a correct combo behaviour. If you need to change it, you need to modify the dhtmlxcombo.js

locate line

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

and replace it with

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

Thanks for reply. It worked.

One small question does dthmlx automplete dropdown support pagination as well?

does dthmlx automplete dropdown support pagination as well?

No, it doesn’t

Hi ,
After changing the js, i find it still can’t works well . Please have a check or a better solution ?
Thanks!

Hi,

After changing the js, i find it still can’t works well . Please have a check or a better solution ?

What exactly doesn’t work well? Please provide the details

After changing the js as above ,i meet the situation:
The select-down has the following values :
v3batchabc, v3batchaby .
when i type ‘‘ab’’, i find the value i just typed was changed to be ‘‘vb’’ ,do you know why that occur? If possible , could you please provide me the updated JS file and send me :
paulojian@hotmail.co.uk

Thanks.

when i type ‘‘ab’’, i find the value i just typed was changed to be ‘‘vb’’

you have typed “a” it finds “v3batchabc” and sets “v”. Then you have typed “b”, it doesn’t find any option and leaves “vb”.

You may try to use one more modification in dhtmlxcombo.js:

locate:

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

and replace it with:

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

It works well now ,Thanks for your great help .Perfect!!

I tried this, but when there is just one option in the list, I can’t choose it. thanks in advance.

I’m sorry to resurrect this old thread, but all tips to change filtering to ‘includes’ does not work.

I am using the latest version of dhtmlxcombo and connector.

I have tried both of these tips:

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

========AND====

if (text!=data[1]){
this.setComboText(data[1]);
dhtmlXRange(this.DOMelem_input,text.length+1,data[1].length);
}
======TO=======
if (text!=data[1]){
dhtmlXRange(this.DOMelem_input,text.length+1,text.length);
}[/code]
Changing both or just one does not enable filtering by includes. After changing the .jv I reload the page. Am I supposed to do something else after changing the two lines?

This solution is for the case when all options are loaded dynamically. Not for dynamic loading. What is the initialization code of your code ?

Code that initializes the combo box:

[code]

<script>
	var z=new dhtmlXCombo("combo2","person",190);
	z.enableFilteringMode(true,"includes/search_com_name.php",true);
	function confirmComboValue(){combo.confirmValue();}
</script>
</form>
[/code]

.php that generates the valid XML to populate the combo box:

[code]<?php
$connection=mysql_connect(“localhost”,“root”,"");
mysql_select_db(“DATABASE”);

require("../java/codebase/combo_connector.php");
$comboconn = new ComboConnector($connection,"MySQL");
$comboconn->render_table("com_people","name","name");

?>[/code]

z.enableFilteringMode(true,“includes/search_com_name.php”,true);

You are using dynamic loading when options are loaded according to the mask. We have not tested the solution with this mode. And moreover, connector returns suggestions for “start with” rule.

What is the initialization code for a combobox that uses filtering? Does that combobox have to be populated with static options? I would still like to load the options dynamically from php.

What is the initialization code for a combobox that uses filtering?

Check the sample dhtmlxCombo/samples/04_filtering/02_combo_filter.html

In this sample 2 last combos using dynamic loading. Others - simple filtering

I would still like to load the options dynamically from php.

In this case connector doesn’t fit, as it returns options for the start with mask. You use own script to generate xml. Something like dhtmlxCombo/samples/04_filtering/php/complete.php, but you need to use another “like” part in SQL query:

$sql = “SELECT DISTINCT item_nm FROM Countries Where item_nm like '%”.mysql_real_escape_string($mask)."%’";

instead of

$sql = “SELECT DISTINCT item_nm FROM Countries Where item_nm like '”.mysql_real_escape_string($mask)."%’";

I have the same problem that the characters are only matched from the beginning of the strings and not anywhere in the string.
I read the modification advice to the .js, yet was unable to locate that exact string in the dhtmlxcombo.js. I’m running v3.

Please advise!
Joe

Okay, got the “contain”-part to work.
Images showing too, after switching completely to the dhtmlXCombo initiation.

Now the only thing that remains unsolved is how to combat lukman’s problem from earlier.
Whenever I type a letter it automatically only shows those results conatining the character.
Unfortunately it replaces the letter with the first matching result, even if I’d like to type some more characters…
The string I am supposed to look for in the js-file is not to be found…again!.

Check post
viewtopic.php?f=4&t=16576#p51269
and also check the server-side part if you are using dynamic loading

In the js-file referenced in the HEAD-tag (codebase/dhtmlxcombo.js) there is no such string.
Only this which looks similar, but with different variables:

if(b){var h=this.getComboText();h!=f[1]&&(this.setComboText(f[1]),dhtmlXRange(this.DOMelem_input,h.length+1,f[1].length))}

On the other hand there is the dhtmlxcombo.js in the sources subdirectory, in which the string exists, but that file is not called in the page header.
After referencing that file and making the advised changes it works!!

Why the two files? And more importantly why is the correct file never referenced in your tutorials?