To define options of combo you should use ComboConnector on the server side and specify the connector file in the load() method on the client side:
client side:
var combo=new dhtmlXCombo("combo_zone2","alfa2",200);
combo.load("http://localhost:8080/connector");
server side:
public class DataBaseConnection {
Connection getConnection(){
Connection conn=null;
try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection(
"jdbc:mysql://localhost/sampledb?characterEncodingTF-8",
"root",
""
);
} catch (Throwable e) {
e.printStackTrace();
}
return conn;
}
}
and
import com.dhtmlx.connector.ConnectorServlet;
import com.dhtmlx.connector.DBType;
import com.dhtmlx.connector.ComboConnector;
import java.sql.Connection;
public class AppServer extends ConnectorServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see com.dhtmlx.connector.ConnectorServlet#configure()
*/
@Override
protected void configure() {
Connection conn = ( new DataBaseConnection()).getConnection();
СomboConnector data = new ComboConnector(conn);
data.render_table("categories","id","valueColumn, labelColumn");
}
}
data.render_sql(
"SELECT *, CONCAT(FirstName, LastName) as label FROM table1",
"id",
"id,FirstName(label)"
);
Note, in the filtering mode Combo filters data by the "label" field.
Back to top