List & Label's powerful filter options could not be used for all data sources so far. Reason is, especially for web based data sources, it is not possible or feasible to get "all" data first and then filter to the desired subset. The upcoming version 24 comes with a powerful new feature that addresses this very issue: Parametrized Data Sources. It allows to combine data source parameters with actual report parameters in the Designer.
So far filter options could not be used with:
As a simple example: For a REST API that provides job data in JSON format, the JsonDataProvider can be used. Important filter criteria (e. g. customer number) usually have to be transferred in the URL of the web service, otherwise too much data would be transferred at once (i.e. it would transfer the order data of all customers).
If the orders are to be filtered for the customer with ID 123, the URL could look like this:
http://example.net/api/customers/123/orders
JsonDataProvider orderData = new JsonDataProvider ("http://example.net/api/customers/123/orders");
Enter the new parametrized data sources feature for LL24 - this allows to combine data source parameters with actual report parameters in the Designer. Even better, a data source can automatically create the report parameters that are required in order to properly use it. They are defined before the Designer is even opened or a print is started.
For data providers that support the new feature, variable parameters can be inserted into the previously fixed options (such as the URL for the JsonDataProvider). This is done with a special syntax.
Examples
http://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/KONSTANZ/W/measurements.json?start=P30D
http://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/{{City=KONSTANZ|choices=KONSTANZ,BONN,KOBLENZ|multiselect=false}}/W/measurements.json?start=P{{ViewDays=30|choices=10,20,30|multiselect=false}}D
This is what the result looks like in the HTML5 viewer: In the Desktop preview:
getOrdersCommand.parameter[0].Value = "{{ClientId=ABC}}""
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _databasePath); conn.Open(); OleDbCommand cmd = new OleDbCommand("SELECT * FROM Customers Where Customers.Country=?", conn); OleDbParameter param = new OleDbParameter("Country", OleDbType.VarChar, 50); param.Value = "{{Country=Germany|choicesfield=Customers.Country}}"; cmd.Parameters.Add(param); OleDbCommand cmd2 = new OleDbCommand("SELECT Customers.Country FROM Customers", conn); DbCommandSetDataProvider prov = new DbCommandSetDataProvider(); prov.AddCommand(cmd, "CustomersFiltered", "[{0}]", null); prov.AddCommand(cmd2, "Customers", "[{0}]", null); using (ListLabel LL = new ListLabel()) { LL.DataSource = prov; LL.AutoShowSelectFile = false; LL.Design(); }
var excelData = new XlsDataProvider(@"\\FileServer\RawData\{{Year=2018|choices=2016,2017,2018}}.xlsx", firstRowContainsColumnNames);
Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.