dhtmlxcombo autocomplete mode,filtering not working

My Question: I have a jsp file which will generate a XML. The XML file is as follows.

<? xml version ="1.0" encoding="UTF-8" ?> CITY STATE COUNTRY REGION I populating this data from xml into dhtmlxcombo. My combo code is as follows,

The data from the XML is getting populated in the combo.
My problem is ,
1.The data is from the Xml is populated more than once in the combo.
2.when i pressed C, City is not getting selected.

the below code is working
var z=new dhtmlXCombo(“loctype”,“alfa1”,155);
z.enableFilteringMode(true);
z.loadXML(“Location.jsp”);

But i want my combo to work under autoComplete mode. Please help.
Thanks in advance

Hi,

please check the sample in the 2.6 package:

dhtmlxCombo/samples/04_filtering/02_combo_filter.html

Your code snippet corresponds the second combo in this sample. Autocomplete is applied in this case. Do you use the latest combo version?

Hi Alexandra,
Thanks. I’m using version 2.5. The version i downloaded has the example what you have said. Based on the example i did, but it is not working. Let me clear you one thing.
Instead of dropdown, i’m using this script,
var z = new dhtmlXCombo(“loctype”,“alfa1”,200);
z.enableFilteringMode(true);
z.loadXML(“Location.jsp”);
The above code is working fine. filtering is happening. data is being populated in the combo only once. But i want the combo to work in autocomplete mode.

For that i’m changing the code as,
var z = new dhtmlXCombo(“loctype”,“alfa1”,200);
z.enableFilteringMode(true,“Location.jsp”,true);

This Location.jsp will create an xml, which will have the data for the drop down.
My Location.jsp is as follows,

<?xml version="1.0" encoding="UTF-8" ?>

<@page contentType=“text/xml”; charset=“UTF-8” %>
<@page language=“java”,import=“java.sql.*;”>//includes all necessary classes.

<%
Connection conn=null;
String url=“jdbc:mysql://192.0.8.78:9999”;//here i’m giving a false data
String dbname=“sa”;
String password=“password”;
class.forName(“conn.mysql.jdbc.Driver”).newInstance();
conn.DriverManager.getConnection(url+dbname+password);
PrepareStatement stmt=null;
ResultSet rs=null;
String sql=null;
int v_loc_type_code=0;
String v_loc_type_desc="";
sql =" select loc_type_code, loc_type_desc from genl_location_type";
stmt=conn.prepareStatement(sql);
rs=stmt.executeQuery();
while(rs.next())
{
v_loc_type_code=rs.getInt(“loc_type_code”);
v_loc_type_desc=rs.getString(“loc_type_desc”);
out.print("<option value=""+v_loc_type_code+"">");
out.print(v_loc_type_desc);
out.print("");
}
rs.close();
stmt.close();
%>

The above code generate a xml file for the drop down data.

But in the documentation it is given that complete.php is working as an additional script for an preloaded combo, and the sql code in php has like command.?

1.Without any additional script cant we make the combo to work under autocomplete mode
2.Problem with the version?
3. For the combo i want the table data loaded from an xml and combo should work in auto complete mode.

But, here data is getting loaded more than once. And if i press any letter suggestion or selection from the combo is not happening for the below code.
var z = new dhtmlXCombo(“loctype”,“alfa1”,200);
z.enableFilteringMode(true,“Location.jsp”,true);

Very sorry for a lengthy question.

Thanks in advance,
Vigneshwarie

Make sure that server-side script returns desired xml for the mask you’ve entered. Also you don’t need to use add=“true” attribute:

instead of

Try using the latest combo version.

Hi,
The jsp file returns the xml file exactly as below.

<? xml version ="1.0" encoding="UTF-8" ?> CITY STATE COUNTRY REGION

Without using any external scripts like complete.php cant we perform autocomplete mode?
If the answer is NO then I can digg with the script.

Hi,

So… you want to use static loading - xml is loaded once. Therefore, enableFilteringMode(true,url) can not be used.
You need to use:
var z = new dhtmlXCombo(“loctype”,“alfa1”,200);
z.enableFilteringMode(true);
z.loadXML(“Location.jsp”);

Regarding autocomplete in this mode - you may try to use the latest version. Probably there is a bug in your version.

Hi Alexandra,
I downloaded new version 2 days back and using.

I created a script for dynamic loading, and as you said, I removed the attribute add=“true” and executed. Now everything is working fine but with dynamic script. I dont want dynamic script.

1.I need autocomplete mode for static script. I’m using latest version.
2.And one more issue, in the drop down list i couldnt see the down arrow. It is empty. I have copied all the images form imgs folder, using the dhtmlxcombo.css, dhtmlxcommon.js and dhtmlxcombo.js
Do i need to change anything else in css file?

Any other way for autocomplete mode for static xml script.

But apart from all these, the Combo is good. Good learning with scripts. Thanks a lot!

With Regards,
vigneshwarie

Hi,

If you want to use static xml you may use:
z.loadXML(“Location.xml”);
instead of
z.loadXML(“Location.jsp”);
Check the sample dhtmlxCombo/samples/04_filtering/02_combo_filter.html

And one more issue, in the drop down list i couldnt see the down arrow.

Make sure that you have defined the image path. For example:

dhtmlx.image_path = “codebase/imgs/”;

Thanks Alexandra, the combo is working fine. The images… i didn’t set the path, now it is displaying.
And I’m having two JSP pages where one is create page(a data entry page) and other is a edit page.
In the create page I’m selecting a location from combo, and data is saved in the DB on submit. When I click the edit button edit page will get opened with all the data in the corresponding fields.( for this I will be querying the DB and display the data in the fields.)
But for combo I could not do this. In a normal drop down list I can do this.
Is there any way to make the data selected while edit button is clicked.

In the DB I will be storing the “value” of the combo. As it is XML file, I couldn’t do.

For a normal drop down list my script will be like this,
for(var i=0;i<=document.getElementById(“p_city”).length-1;i++)
{
document.getElementById(“p_city”)[i].selected=true;
}

The above will be working fine where in drop down list I will be getting the index number. But in XML I cant.
Help me.

Thanks in Advance.
Vigneshwarie

There are several ways to select combo option:

  • by option index

z.selectOption(optionIndex);

  • by option value

z.setComboValue(optionValue);

Thanks Alexandra.

I have applied your suggestions, its working fine.

Thanks to the effort of Support Team.

Nice Product!

With Regards,
vigneshwarie