Check documentation for the latest version of dhtmlxSuite Connector object DHTMLX Docs

Connector object

add

(available from version 2.0 and applicable just to MixedConnector)

adds a configured connector object to a collection for further retrieving the entire collection from the server.

$conn->add($name, $config);

Parameters:

  • $name - the name which will be assigned to a data block (configured by the specified connector object) in the final retrieved JSON object
  • $config - the connector object. You can use just connectors that generate 'JSON' data feed

See also:

add_section

(available from version 1.5 and applicable just to DataConnector/JSONDataConnector)

adds the first child tag(section) to data.

$conn->add_section($name, $value);

Parameters:

  • $name - the section name
  • $value - the section value

See also:

asString

(available from version 2.0)

allows getting data generated by dhtmlxConnector as a string. Once the functionality is activated, dhtmxConnector starts to return data as a string instead of direct loading into the client.

$conn->asString($isActive);

Parameters:

  • $isActive - (boolean) activates/disables the functionality. By default is false.

See also:

configure

configures the connector without rendering data.

$conn->configure($table,$id,$text,$extra,$relation);

Parameters:

  • $table - the name of a table.
  • $id - the name of the id field.
  • $text - a comma separated list of data fields.
  • $extra - a comma separated list of extra fields, optional.
  • $relation_id - used for building hierarchy in case of Tree and TreeGrid.

See also:

dynamic_loading

enables the dynamical loading mode for connector.

$conn->dynamic_loading([$rowsNum]);

Parameters:

  • tree, treegrid - no parameters
  • grid - the number of rows which should be initially loaded (the value should be more than the number of rows visible in grid, or at least any positive number)
  • combo - the maximum number of options which the server will send for a single data request in autocomplete mode

See also:

enable_log

enables logging for connector.

$conn->enable_log("path to log file");

Parameters:

  • path - absolute or relative path to text file where log will be written.

See also:

filter

(available from version 2.0)

filters a dataset on the server side.

$conn->filter($name,$value);
//or
$conn->filter($sql_str);

Parameters:

  • $name - the name of a field
  • $value - the filtering criteria

  • $sql_str - the sql statement specifying the filtering logic See also:

  • Filtering

is_select_mode

returns current active mode.

$conn->is_select_mode();

Parameters:

  • none.

Returns:

  • true, if select mode is active.
  • false, if update mode is active.

mix

(available from version 2.0)

has 2 overloads:

1) adds a custom key:value pair(s) to all items of the dataset.

$conn->mix($key,$value);

Parameters:

  • $key - the key of an item (an unique identifier)
  • $value - the actual data item

2) provides querying data from two tables, based on a relationship between the specified columns in these tables. Used with render_table method that defines configuration of the primary table

$conn->mix($table, $config, array ($fkey => $pkey));

Parameters:

  • $table - the name of the child(joined) table
  • $config - the connector object of the child table
  • $fkey - the foreign key
  • $pkey - the primary key

See also:

render

retrieves configured data from the server. Applicable just to MixedConnector.

$conn->render();

See also:

render_array

configures connector and retrieves data from a PHP array which can be filled by any kind of external logic.

$conn->render_array($data,$id,$text,$extra,$relation_id);

Parameters:

  • $data - the name of a PHP array.
  • $id - the name of the id field.
  • $text - a comma separated list of data fields.
  • $extra - a comma separated list of extra fields, optional.
  • $relation_id - used for building hierarchy in case of Tree and TreeGrid.

See Also:

render_sql

configures connector and retrieves data based on provided SQL text.

$conn->render_sql($sql,$id,$text,$extra,$relation_id);

Parameters:

  • $sql - any sql code, which will be used as a base for data selection.
  • $id - the name of the id field.
  • $text - a comma separated list of data fields.
  • $extra - a comma separated list of extra fields, optional.
  • $relation_id - used for building hierarchy in case of Tree and TreeGrid.

See Also:

render_complex_sql

configures connector and retrieves data based on provided SQL text.

Works similar to render_sql, but have 2 differences:

  1. Uses provided sql exactly as it is;
  2. Can be used only for data loading (for data saving you can use separate connector, event handlers, or custom model).

The method can be used to call stored procedures in the database.

$conn->render_complex_sql($sql,$id,$text,$extra,$relation_id);

Parameters:

  • $sql - any sql code, which will be used as a base for data selection or the name of a stored procedure.
  • $id - the name of the id field.
  • $text - a comma separated list of data fields.
  • $extra - a comma separated list of extra fields, optional.
  • $relation_id - used for building hierarchy in case of Tree and TreeGrid.

See Also:

render_table

configures connector and retrieves data from single table.

$conn->render_table($table,$id,$text,$extra,$relation);

Parameters:

  • $table - the name of a table.
  • $id - the name of the id field.
  • $text - a comma separated list of data fields.
  • $extra - a comma separated list of extra fields, optional.
  • $relation_id - used for building hierarchy in case of Tree and TreeGrid.

Description:

  • If you want to render all fields from DB ( except of identity field), you can use simplified command:
$conn->render_table($table);

See Also:

set_encoding

allows you to set encoding that will be applied to generated XML (default encoding is UTF-8).

$conn->set_encoding("iso-8859-1");

Parameters:

  • encoding name.

set_limit

limits the number of data items that will be loaded to a component.

$conn->set_limit([$rowsNum]);

Parameters:

  • the number of data items which should be loaded

set_options

creates a collection of options (attaches OptionsConnector to gridConnector or schedulerConnector). Applicable to gridConnector or schedulerConnector only

$list = new OptionsConnector($res, $dbtype);//initializes OptionsConnector
$list->render_table(
    "types",
    "type_id",
    "type_id(value),name(label)"
); //retrieves data from the 'types' table
 
$scheduler = new schedulerConnector(
    $res, 
    $dbtype
);//initializes schedulerConnector
 
//attaches OptionsConnector to schedulerConnector
$scheduler->set_options("my_collection", $list);

Parameters:

  • the name of a collection
  • the OptionsConnector object

sort

(available from version 2.0)

sorts a dataset on the server side.

$conn->sort($name,$direction);
//or
$conn->sort($sql_str);

Parameters:

  • $name - the name of a field
  • $direction - the sorting direction ("ASC" or "DESC")

  • $sql_str - the sql statement specifying the sorting logic

See also:

Back to top