Page 1 of 1

Filter variables by columns chosen to compile in report

Posted: Thu Jan 30, 2014 5:50 pm
by theregister
Hello again. I really need to find a way to make something like this:

Say we want our application to show the user specific variables depending upon which dataSource the user selects. For example, if the user chooses the clients datasource, then the application must show him only filters that have something to do with the clients datasource, such as a client code range or something like that. But when the user deletes that databand from the report and drags a new one, say the supplies datasource, then the application must hide all the previous filters, and show him, again, only the relevant ones, such as a supplies code or something. Now, we are currently able to do this via the StiDataSourceHelper class, using the GetUsedDataSourcesNamesList function to get the datasource the user is using, and therefore via our application decide which variables are shown and which are not, we currently do this already.

However, there may be times when the user may select that same clients datasource, but it has many fields, and maybe the fields he wants to select out of that datasource, have nothing to do with many of the filters that will be added automatically once the program sees he selected the clients datasource. Management feels having 20 filters shown and only 3 useful to the report is a no-no. But since we don't know which columns he selected out of that datasource we cannot filter better the filters that will be shown to him. I understand this may seem too much work for a single report, but it's what management is asking for anyway.

So the question remains, what can we do to achieve this? I understand the StiDataSourceHelper class will only work with data sources, as the name says, but we need to find a way to give our application the information about what columns are being chosen to be shown. I mean somewhere Stimulsoft must know which columns are being chosen, because it only shows those columns after the report is compiled, and that's the data we need. So maybe if StiDataSourceHelper is not gonna help, is there another class that will? I understand this may not be your typical request, but something like this must exist, since even Stimulsoft by itself uses it. I hope we can work this out and thanks for your input.

Re: Filter variables by columns chosen to compile in report

Posted: Fri Jan 31, 2014 8:28 am
by HighAley
Hello.

It's possible to know by going through all report components.

You could use next code:

Code: Select all

foreach (StiComponent comp in rep.GetComponents())
{
    StiText txt = comp as StiText;
    if (txt != null)
    {
        // you could get expression from this property txt.Text 
    }
}
Using this code you could parse expressions used in report and show only necessary filters.

Thank you.

Re: Filter variables by columns chosen to compile in report

Posted: Tue Feb 04, 2014 7:28 pm
by theregister
Well this seems to do the job, I managed to loop through the components and filter the variables programatically that way. I'm glad to know this support team is here for when we need to accomplish more complicated tasks such as this. Thanks and we hope to be using Stimulsoft for a long time.

Re: Filter variables by columns chosen to compile in report

Posted: Wed Feb 05, 2014 6:16 am
by Andrew
Hello,

Thank you for the good words. We shall keep on providing the timely and sufficient support.

Have a good day!

Re: Filter variables by columns chosen to compile in report

Posted: Thu Feb 06, 2014 4:55 pm
by theregister
We noticed this method only works with the columns first picked when selecting a data source, meaning that if we later on add a column straight from the datasource into the databand it will compile and show its data, but it won't be shown as a component? Are these new fields not components? And if not, what could we do to evaluate them as well?

Re: Filter variables by columns chosen to compile in report

Posted: Fri Feb 07, 2014 8:00 am
by HighAley
Hello.

Please, send us a sample project and step-by-step instruction how to reproduce your issue.

Thank you.

Re: Filter variables by columns chosen to compile in report

Posted: Sat Feb 08, 2014 12:27 am
by theregister
It's basically the same as before, this is what I'm doing on the application when I click on the Preview tab:

Code: Select all

For Each comp As StiComponent In Report.GetComponents
    '
    'Some filters to get only the components I need
    '
    Select Case column
        Case "someColumn"
            Report.Dictionary.Variables("someVariable").RequestFromUser = True
    End Select
Next
So when I load the application, choose a datasource, choose the columns I want in the report like this: Image
Accept everything and finally click on the Preview tab, it will start compiling, and it will show me the variables I need depending on the columns I chose, so it works great.

The issue however is when, after all that, I go back to Page1, and decide to add another column to my databand, say I had added columns A, B and C previously, so now I decide I also want column D in the report, I drag and drop it from the same datasource I selected previously and into the same databand I already have working on the report, making sure it fits, of course. So now I go back to the Preview tab and compile this report, and it will show me the data from the column I chose a minute ago as well as the others, however, the program never detects the new column as a StiComponent, I tried debugging and indeed it only catches the components that were added when the databand was first added, not when new columns were added to it, so even if the report is showing the content of columns A, B, C and D, it will only find the components A, B and C.

What could we do here?

Re: Filter variables by columns chosen to compile in report

Posted: Mon Feb 10, 2014 8:26 am
by HighAley
Hello.

Sorry, but we couldn't reproduce your issue.
Where do you use your code to go through all components?
Maybe you could send as a sample project?

Thank you.

Re: Filter variables by columns chosen to compile in report

Posted: Mon Feb 17, 2014 4:13 pm
by theregister
Hi again,

this behaviour isn't tied to a specific report, it happens in any.

These are the steps:

1. Drag any datasource to the report designer and select columns A, B and C.
2. Preview the report (Here it gives me components A, B and C)
3. Return to the design view.
4. From the dictionary, drag another column (D) from the same datasource to the report's databand.
5. Preview the report again (Here it will give me components A, B and C again, but no D)

So the problem is that the components code, that I sent before (it's up there), does give me the components from the report, but only the first ones that were added when the datasource was originally added, not the ones that were added later when the report was modified, this can be checked while debugging the project.

And I added the code in the GlobalEvents_ReportCompiling method, which is executed whenever the user clicks on the Preview tab button.

And it actually looks more like this:

Code: Select all

Report.Dictionary.Variables("VariableA").RequestFromUser = False
For Each comp As StiComponent In Report.GetComponents
            Dim component As String = comp.ToString
            If component.Substring(0, 4).Equals("Data") Then
                If component.Contains("_") Then
                    Dim column = component.Substring(component.IndexOf("_") + 1)
                    Select Case column
                        Case column.Contains("ValueA") 
                            Report.Dictionary.Variables("VariableA").RequestFromUser = True
                    End Select
                End If
            End If
        Next
Thanks for your time.

Re: Filter variables by columns chosen to compile in report

Posted: Tue Feb 18, 2014 6:44 am
by Alex K.
Hello,

We couldn't reproduce this bug.
Can you please send us your report with test data which reproducde the issue for analysis.

Thank you.