JSONCommonConnector and server side column sorting


Discovered a problem with the column sorting in grid when using this connector. What is happening is that when the sort SQL is composed via the dhx_sort[n] it is not translating the n into a column name and hence failing.

I have applied the following fix and thought I’d share in the hope that it will be incorporated in the next release.

BaseConnector.java is_select_code() re-written as:

	 * Checks if current mode is a select mode.
	 * @return true, if current mode is a select mode
  public boolean is_select_mode(){
		boolean editing = false;

    if (http_request.getParameter("editing")!=null)
      editing = true;

    if (http_request.getParameter("ids")!=null)
      editing = true;

    return !editing;

JSONCommonConnector.java Add new override method resolve_parameter(String name) to correctly resolve dhx_sort[n] into a column name:

  /* (non-Javadoc)
    * @see com.dhtmlx.connector.BaseConnector#resolve_parameter(java.lang.String)
  protected String resolve_parameter(String name) {
    try {
      int index = Integer.parseInt(name);
      return config.text.get(index).db_name;
    } catch (NumberFormatException nfe) {
      return super.resolve_parameter(name);
    } catch (IndexOutOfBoundsException iobe) {
      return super.resolve_parameter(name);