Filtering allows you to extract specific subsets of data that meet certain criteria. This is essential when you only need to view or work with a portion of the data that is relevant. Filtering helps in exploring and analyzing data more effectively by focusing on specific attributes or conditions. For example, filtering customer data based on location or purchase behavior can provide insights for targeted marketing strategies.
In FlexReport, the data is filtered by using the Filter property of the DataSource class. Using a filter is similar to specifying a WHERE clause in the SQL statement. Suppose you want to know how many times a product is available in the loaded report using the product id (Pid) of the product. You need to add the following code to Filter the product detail corresponding to the product id.
C# |
Copy Code
|
---|---|
<c1:C1FlexViewer Name="flexfilterviewer" HorizontalAlignment="Left" Height="633" VerticalAlignment="Top" Width="958" Margin="0,28,0,0"/> <Button x:Name="btnfilter" Content="Filter Report using Product ID" Click="btnfilter_Click" HorizontalAlignment="Left" VerticalAlignment="Top" Width="171" Margin="300,5,0,0"/> <TextBox x:Name="txtpid" HorizontalAlignment="Left" Margin="150,5,0,0" VerticalAlignment="Top" Width="121"></TextBox> <Label Content="Enter Product ID:" HorizontalAlignment="Left" VerticalAlignment="Top" Width="121" Margin="43,0,0,0"/> |
C# |
Copy Code
|
---|---|
flexReport.DataSource.Filter = "PiD ='" +txtpid.Text+"'"; flexReport.Render(); |