Condition into Report (AB1)


Andrea

Hello, Is possible insert a condition into HTML?

I have a variable into html, [Record.status].

I would like that if the state of [Record.status] is 'processing' it shows some text (example), otherwise not

Thank you


DecSoft

Hello Andrea,

You can use the "ng-show" directive in a way like below:



Andrea
always wonderful! everything is always possible! :) Thank you David

Andrea

Do I like to complicate my life? What am I doing wrong?


DecSoft

Hello Andrea,

There are various ways to do it. I prefer to do these things in the server side, so, our records can have a property like "IsToday", so we can simply prepare a code like below:

If you prefer to rely on the client side, you can prepare a variable in the Show event of the view in wich you place your Report control, a variable like below:

Doing that you prepare a code inside the Report like below:

Of course, we suppose that "Record.MyDate" contains date values like "YYYY-MM-DD". If there is other formatted date string in "Record.MyDate", then you must change the "TodayFormatted " variable accordingly.



Andrea

many things I ask you to learn (I know for sure that with HTTP client and server side everything would be easier)

I would like to use this second method more

The problem is: Record.date_created is y-MM-dd hh:mm!

for this I'm looking for a solution for Record.date_created | date: 'dd-MM-y' otherwise the condition of equality never occurs


DecSoft

Hello Andrea,

You must lost the fear to use an HTTP client control: in fact when you set an URL to the Report, internally an HTTP call is made, so, using an HTTP call to retrieve the data is just a simple step. If you use an HTTP client control you can work with the response before assign it to the "Report.Data" variable.

Suppose the report's source (which will be assigned to the Report's Data variable) contains properties like this: "date_created": "2022-03-15 13:00". You can use an HTTP client control to get the source, and, in the HTTP client control Success event, you can write a code like below:

Doing that you can use a code like below in the Report HTML:



Andrea

Hello David, I hope you are doing wonderfully well, I would need to know if this condition technique is also applicable outside reports (without using reports), in an html that has an ID that has an attribute.

For example I have an ID that has attribute volume=1 and I would like the text "MINIMUM" to be displayed in the div.

how should i do if it is possible to create the condition like your above examples.

it might be interesting to know if it is possible to do something similar also starting from a variable SetVar "volume" "1" "String"

if it is possible in the html check the condition

Thank you


DecSoft

Hello Andrea,

Yes; it's possible to use these kind of conditions in HTML controls, not only in Reports. Talking about AB1, we are talking about something like below, taking in consideration that "volume" is a variable defined with "SetVar":

The below is also possible:



Andrea

Thanks David, good to know.

I was also thinking of another method via css.

I have many divs with the volume attribute.

The volume goes from 0 to 4.

I was thinking of such a solution to avoid writing conditions for each div.

do you think it is a suitable solution?


DecSoft

Hello Andrea,

If the solution using CSS can be good for you, I think there is not a problem to use it: finally we can almost always choose different paths to get our expected results. However, note a couple of things. First of all, in order to avoid the conditions, you are using various CSS rules: so, in fact you "avoid" conditions but used various CSS rules.

On the other hand, the "volume" attribute is not an standard attribute, so, maybe you must avoid it. Maybe you can use a "data-volume" attribute and use your technique with CSS rules, in order to avoid to use a non standard attribute like "volume". On the other hand, if you use HTML, then you can may use different texts (in variables) that you cannot use in CSS.

In principle is not a problem to use the conditions in the HTML, so, I think that in your shoes that is the solution that I will take (in fact the conditions are a very powerful tool that we can use when needed), however, as I said above, if you get the things working as you expected using CSS, then use CSS, Andrea.



Andrea

Thank you David,

Yes it is always nice to study more suitable solutions based on what is needed, thanks for your support ;)


DecSoft

Hello Andrea,

No problem. Just in case you want to use a "data" attribute in the DIV, here is the way to do it (talking about AB1):

And then in the CSS we can apply rules like below:


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.