Check documentation for the latest version of dhtmlxSuite dhtmlxDataJsonConnector and dhtmlxDataConnector DHTMLX Docs

dhtmlxDataJsonConnector and dhtmlxDataConnector

Common

There are 2 connectors you can use for touch-oriented DHTMLX libraries (such as DataTable, DataStore):

  • dhtmlxDataJsonConnector
  • dhtmlxDataConnector

They work in the same way but differ in type of returned data.

The connectors support a simple data transfer protocol.

var connector = new dhtmlxDataJsonConnector(
    "users",
    "name,age,group_name,city,phone,sex,driver_license",
    "id",
    dhtmlxDatabaseAdapterType.SqlServer2005,
    ConfigurationManager.ConnectionStrings["SamplesDatabase"].ConnectionString
);

dhtmlxDataConnector

dhtmlxDataConnector generates 'XML' data feed as in:

<data>
   <item id="1" title="War and Peace"  author="Leo Tolstoy"/>
   <item id="2" title="Hamlet"         author="William Shakespeare"/>
   <item id="3" title="Madame Bovary"  author="Gustave Flaubert"/>
</data>

dhtmlxDataJsonConnector

dhtmlxDataJsonConnector generates 'JSON' data feed as in:

[
   { id:"1", title:"War and Peace",    author:"Leo Tolstoy" },
   { id:"2", title:"Hamlet",           author:"Shakespeare" },
   { id:"3", title:"Madame Bovary",    author:"Gustave Flaubert" }
]

Adding tags/sections to data

Starting from version 1.5, there is a possibility to add the first child tags, sections to data returned by the connector. Tags(sections) are added to the Sections dictionary of the connector:

dhtmlxDataConnector

For example, if you add a tag as follows:

connector.Sections.Add("config", "some_data");
connector.Sections.Add("config2", "<column>value1</column><column>value2</column>");

dhtmlxDataConnector produces the next data:

<data>
    <config>some_data</config>
    <config2><column>value1</column><column>value2</column></config2>
    <item id="1" attr1="qwe" attr2="asd" />
    <item id="2" attr1="qwe" attr2="asd" />
</data>

dhtmlxDataJsonConnector

If you add a section as follows:

connector.Sections.Add("config", "'some_data'");
connector.Sections.Add("config2", "{ column1: 'data1'}");

dhtmlxDataJsonConnector produces the next data:

{
    data: [
      { 'id': '1', 'attr1':'qwe', 'attr2':'asd'},
      { 'id': '2', 'attr1':'qwe', 'attr2':'asd'}
    ],
    config: { 'some_data' },
    config2: { 'column1':'value' }
}

Simple Data Transfer

dhtmlxDataJsonConnector/dhtmlxDataConnector supports simplified protocol for CRUD requests

  • get all data
 GET  data.ashx?action=get

server response - collection of json (xml) objects

  • get info for some specific record
 GET  data.ashx?action=get&id=123

response - json(xml) object

  • delete
 GET  data.ashx?action=delete
 POST id=123

server response - 'true'/'false'

  • insert
 GET  data.ashx?action=insert
 POST id=123&some=value&other=value

response on success

true
<new_id>

or

 false

on failed insert operation

  • update
 GET  data.ashx?action=delete
 POST id=123&some=value&other=value

response - 'true'/'false'

Back to top