Find a row in a DataTable using expression

Stimulsoft Reports.NET discussion
Post Reply
Fuglesteg
Posts: 10
Joined: Tue Jul 09, 2013 7:34 am

Find a row in a DataTable using expression

Post by Fuglesteg »

Hello,

I am trying to initiate a user requested variable by an expression. I need to find the row Concepts.Name = "TCId" and return a value from that row in the column Concepts.Description. Could you please help me with this? The Concept.Description column contains RTF text. Is it possible to convert this to string?

Thank you,

Anders
Fuglesteg
Posts: 10
Joined: Tue Jul 09, 2013 7:34 am

Re: Find a row in a DataTable using expression

Post by Fuglesteg »

I have succeeded in initiating a variable by entering a rendering event in the Report.
RenderingEventOverview.png
RenderingEventOverview.png (14.4 KiB) Viewed 2394 times
The code:
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
string temp="";
Concepts.First();
while(!Concepts.IsEof)
{
if (Concepts.Name=="StTeamcenter ID")
temp=Concepts.Description;
Concepts.Next();
}
// Use the RichTextBox to convert the RTF code to plain text.
rtBox.Rtf = temp;
strTCDoc = rtBox.Text;

The variables show correctly in the report, but if I allow the user to change the values of the attribute, the parameter input field is not populated with the values from the DataTable. This step has to be done for all required variables.

1. Would you say this is an OK approach or could this be done more effectively?
2. Would it be possible to achieve the same with an expression? E.g. By creating a function that can be called by an "init by" expression script.

Thank you
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Find a row in a DataTable using expression

Post by HighAley »

Hello.

Could you describe what do you want to get?
Please, describe what behaviour should report have and we will propose you better solution.
Could you also send us your report template with sample data for analysis?

Thank you.
Fuglesteg
Posts: 10
Joined: Tue Jul 09, 2013 7:34 am

Re: Find a row in a DataTable using expression

Post by Fuglesteg »

Hello Aleksey,

I am unable to provide you with sample data, as this is generated by Visure Requirements. You probably wouldn't have much use of the template either without the sample data. I will try to explain the best I can what I want to achieve here.

I am using the report designer to create a report that contains all the meta data necessary for filing in our PLM software. These values are stored in the Visure Requirements database in the "Concepts" data table. The entries in the column Concepts.Name is used as key column and does not change. I need to display five values from the column Concepts.Description column on the front page of my report, and I need to identify those five values using the Concepts.Name column. The sample code in my previous post shows how I find one such Concept.Description column, and saves it as plain text in the variable strTCDoc. strTCDoc is shown on the front page of the report as a text box.

Now, if I where to set the variable strTCDoc as Request from user. The value displayed in the variable input field in preview mode is not the same as the value shown in the generated report.

So, if I was able to replace my code from the previous post with Init by: expression, expression = ???
Edit variable.png
Edit variable.png (30.06 KiB) Viewed 2383 times
or by entering a expression directly in a text component:
Front Page.png
Front Page.png (67.02 KiB) Viewed 2383 times
that could find a row based on Concept.Name column, and get the value from Concept.Description column it would be great.

Note: I did this using data bands earlier, but as you may imagine, it became a mess with all the databands and panels on the front page.

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Find a row in a DataTable using expression

Post by HighAley »

Hello.

You could try to use Get Value event of the text component.

Thank you.
Post Reply