You can assign aliases to the required tables or columns. For this purpose, use the word 'as' (as in any usual sql statement) in your connector's constructor.
dhtmlxTreeConnector connector = new dhtmlxTreeConnector(
"Folders",
"FolderID AS ID",
"ParentID",
dhtmlxDatabaseAdapterType.SqlServer2005,
ConfigurationManager.ConnectionStrings["SamplesDatabase"].ConnectionString,
"FolderName AS Text"
);
To attach event you should use EventHandler<...>. For more details on this topic, see the 'Event handling' quide.
connector.BeforeUpdate += new EventHandler<DataActionProcessingEventArgs>(
connector_BeforeUpdate
);
void connector_BeforeUpdate(object sender, DataActionProcessingEventArgs e)
{
//custom code
}
To add a custom error message you can use the event onDBError and write the desired message in the appropriate handler.
public void error_details(object sender, DataActionProcessingEventArgs args)
{
args.DataAction.Details = "DB operation was failed";
}
connector.OnDBError += new EventHandler<DataActionProcessingEventArgs>(error_details);
By default, connector allows all operations. To deny some operation use deny(name_of_operation) method that can get one of the following:select/update/insert/delete/all/none. For more details see 'Security' guide.
connector.Request.AllowedAccess = AccessRights.Update;
You can use the ItemPrerender event to define how the content of a cell must be formatted.
dhtmlxGridConnector connector = new dhtmlxGridConnector(/*...*/);
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";
}
You have 3 ways to filter data on the server backend:
grid.load("some.ashx?connector=true&dhx_filter[1]=mask");
mygrid.setHeader("Column A, Column B");
mygrid.attachHeader("#connector_text_filter,#connector_select_filter")
connector.BeforeSelect += new EventHandler(connector_BeforeSelect);
void connector_BeforeSelect(object sender, EventArgs e)
{
this.Connector.Request.Rules.Add(
new FieldRule("CreatedDate", Operator.GreaterOrEqual, "2009-01-01")
);
}
See the guide 'Filtration' for more information.
You can enable logging by means of using the Log.Enabled property. For more details see the 'Error handling and logging' guide.
connector.Begin += new EventHandler(connector_Begin);
private StringBuilder _LogContent = new StringBuilder();
void connector_Begin(object sender, EventArgs e)
{
Log.Enabled = true;
Log.Listeners.Add(new TextWriterTraceListener(new StringWriter(this._LogContent)));
}
You have 2 ways to sort data on the server backend:
grid.load("some.ashx?connector=true&dhx_sort[2]=asc");
grid.setColSorting("connector,str,na);
See the guide 'Sorting' for more information.
dataProcessor lets you validate data on the client side. Use the setVerificator(index,method) method to define the appropriate columns and validators. See details in the related chapter of dataProcessor's documentation.
dp.setVerificator(column_index,verification_func)
To perform server-side validation you should use one of the dhtmlxConnector events stated below and specify the needed validation rules in the appropriate events' handlers functions:
connector.BeforeInsert += new EventHandler<DataActionProcessingEventArgs>(
connector_BeforeInsert
);
void connector_BeforeProcessing(object sender, DataActionProcessingEventArgs e)
{
if (string.IsNullOrEmpty(e.DataAction.Data[(TableField)"title"]))
...
}
For more details on the server-side validation, see the guide 'Validation'.
Back to top