The BeforeSelect event fires exactly before data will be selected. This is the place when you have last chance to modify select parameters before result will be available. You can use it also to add some additional rules or OrderBy statements. E.g. Both Grid and TreeGrid use this event to include extra fields collection into requested fields collection.
public dhtmlxGridConnectorBase() { this.BeforeSelect += new EventHandler(dhtmlxGridConnectorBase_BeforeSelect); } void dhtmlxGridConnectorBase_BeforeSelect(object sender, EventArgs e) { this.Request.RequestedFields = this.Request.RequestedFields.Union(this.ExtraFields).ToFieldsCollection(); }
Code above keeps untouched Request.RequestedFields collection until last moment and then adds some more fields into it to be requested. The same way you can get or set index of row to start selection from (Request.StartIndex), rows count to be retrieved (Request.Count), selection or sorting rules (Request.Rules and Request.OrderBy), or even table name selection will go through (Request.TableName).