# Global Event: OnDataFieldsRetrieved

The OnDataFieldsRetrieved Event occurs after Data Fields are retrieved for a specific Data Object. This event is commonly used to change the order Data Fields are displayed in the Data Menu of the Report Designer.

Signature

For custom code the args array is structured as follows:

args[] is contains three objects, the first a System.Data.DataTable containing the names and metadata of the Data Fields, the second the Data Object as a WebReports.Api.Reports.Entity object, the third a reference to a WebReports.Api.Data.DataObjectBase object which calls the event.

For .Net Assemblies the method signature is as follows:

string EventHandlerName(SessionInfo sessionInfo, DataTable originalDataFields, Entity dataObject, DataObjectBase eventCaller)

Expected Return

Expects a System.Data.DataTable return value, which represents the modified data.

Notes

The DataTable being being passed to the event in the first argument has already applied Column Metadata.

Example

The following example shows how the fields could be displayed in reverse alphabetic order.

    //this code example makes reference to System.Data.dll and System.xml.dll and uses the namespaces Syste.Data, WebReports.Api.Reports and WebReports.Api.Data

    DataTable dt = args[0] as DataTable;
    DataView dv = dt.DefaultView;
    dv.Sort = “column_name desc”;
    return dv.ToTable();