Check documentation for the latest version of dhtmlxSuite Data Loading HowTos DHTMLX Docs

Data Loading HowTos

How can I enable dynamic loading?

To enable dynamic loading you should:

  • enable the related mode on the client side (e.g. smart rendering or paging for grid)
grid.enableSmartRendering(mode,buffer);
  • on the server side use one of the two properties: EnableDynamicLoading (for tree/treeGrid) or SetDynamicLoading (for grid/combo).
dhtmlxTreeConnector treeConnector = new dhtmlxTreeConnector(/*.....*/);
treeConnector.EnableDynamicLoading = true;
 
dhtmlxGridConnector gridConnector = new dhtmlxGridConnector(/*.....*/);
gridConnector.SetDynamicLoading(30);

See the guide 'Dynamic loading' for more information.

How can I format/change data before loading?

To set some specific formatting or change data before sending to the client side, you should use the ItemPrerender event handler. For more details on this topic, see 'Formatting/Changing Data before Loading'

connector.ItemPrerender += new EventHandler<ItemPrerenderEventArgs<dhtmlxGridDataItem>>(
connector_ItemPrerender
);
 
void connector_ItemPrerender(object sender,ItemPrerenderEventArgs<dhtmlxGridDataItem> e)
{
    if (e.DataItem.Index % 2 == 0)
    e.DataItem.BgColor = "gray";
}

How can I load data from a database table?

To load data from a database table you should use one of two ways:

  • To initialize the connector by SQL query, from where it will take the table name, filtering and ordering rules, the columns' list, etc.
dhtmlxGridConnector connector = new dhtmlxGridConnector(
   "SELECT ISO, PrintableName FROM Country",
   "UID",
   dhtmlxDatabaseAdapterType.SqlServer2005,
   ConfigurationManager.ConnectionStrings["SamplesDatabase"].ConnectionString
);
  • To pass the table name and columns separately.
dhtmlxGridConnector connector = new dhtmlxGridConnector(
   "BookStore",
   "sales, title, author, price, instore, shipping, bestseller, pub_date",
   "book_id",
   dhtmlxDatabaseAdapterType.SqlServer2005,
   ConfigurationManager.ConnectionStrings["SamplesDatabase"].ConnectionString
);

How can I send additional information to the client side?

To send additional information that won't be outputed but you'll have access to, to the client side, use the optional constructor parameter - ExtraColumnNames. With the help of this param, you can specify the columns that contain the desired additional information.

dhtmlxGridConnector connector = new dhtmlxGridConnector(
   //SQL with inner join statement 
  "SELECT UID,
  PrintableName,
  TimeZone,
  TZID FROM Country INNER JOIN Timezone ON Country.TZID = Timezone.TZID",
  "UID",//Primary key name
  dhtmlxDatabaseAdapterType.SqlServer2005, //Database adapter type 
  //connection string
  ConfigurationManager.ConnectionStrings["SamplesDatabase"].ConnectionString, 
  "TZID"//This column will be requested, appear in all events, but won't be rendered
);

For more information, see the chapter 'Using extra fields' in the 'Basic Loading' guide.

Back to top