Scroll

Global Event: OnLoadReportParameters

The OnLoadReportParameters event passes a list of Parameter elements that can be reordered or modified before they are sent to the client for display. Called when report parameters are loaded, but before any processing has occurred. By default, parameters are sorted alphabetically by name.

Signature    

For custom code the args array is structured as follows:

args[] is contains one object, a list of Parameter elements.

For .Net Assemblies the method signature is as follows:

void EventHandlerName(SessionInfo sessionInfo, List<Parameter> parameters)

Expected Return

The event has a void return value.

Example

The following example sorts Parameters based on their dependencies on each other in custom SQL.

List parameters = args[0] as List;
List sortedParameters = new List();

string paramPattern = @"@\w+@";

foreach(Parameter p in parameters) {

    int minPosition = 0;
    foreach (Match m in Regex.Matches(p.DropdownSqlStmt, paramPattern))
    {
        string matchedParamName = m.Value.Replace("@","");
        int matchIndex = sortedParameters.IndexOf(matchedParamName);
        Logger.Instance().Info("Found instance of " + matchedParamName + " (at index " + matchIndex + ") in parameter " + p.Id);
        if(matchIndex >= minPosition)
            minPosition = matchIndex+1; //Needs to go after this since it is dependent upon it
    }
    sortedParameters.Insert(minPosition, p.Id);
}
parameters.Sort((a,b) => {
    int a_order = sortedParameters.IndexOf(a.Id);
    int b_order = sortedParameters.IndexOf(b.Id);
    if(a_order >= 0 && b_order >= 0)
       return (a_order - b_order);
    return 0;
});
for(int i=1; i<parameters.Count; i++) {
    parameters[i].IsEnabled = false;
}
return null;

Hidden Article Information

Article Author
Exago Development
created 2017-02-21 16:09:21 UTC
updated 2017-06-27 14:40:22 UTC

Labels
Server Events, parameters, event handlers, list of server events, load, report, params, loadreportparameters, loadparameters, loadparams,
Have more questions? Submit a request