Passing parameter value to hiding element expression. BIRT - report

I am trying to pass a parameter value to the hiding column element (in a table) in the expression box, so that if the value it's false it will not show the column.
Ex: my parameter is an int ( 2013 or 2014 or 2015..)
I tried the following but with no succes:
if(params["pStartEI"].value > 2014)
this.getStyle().display="none";
else
this.getStyle().display="block";
or the following:
if(params["pStartEI"].value > 2014)
{
true;
}
false;
Please tell me if you encountered this.
Thank you.

Try the following
if(params["pStartEI"].value > 2014)
{
true;
}
else
{
false;
}

Related

How to check if variable is not exist

I can't find in docs how I can do negative statement like one below:
if !($some_var) {
... enter here if $some_var doesn't exist or empty
}
I know that I can check that the variable is exits using the if statement:
if ($some_var) {
...
}
But I can't find how to do if not statement
Is it possible for NGINX?
Try this:
if($var = false) {
....
}

Regex to validate dropdown entries

I have a dropdown in which I am having
"-- Select--"
as the first item. I want to check if user has choosen something else from the dropdown instead of Select.
So is there a way around to match if
!-- Select --.
I have done this till now.
"regex": /^[!-- Select --]$/,
Where "!" means when not Select.
I am achieving this client side.
You can try this regex:
/^(!?--\s*[Ss]elect\s*--)$/
You should also find SelectedIndex property to evaluate this item.
It doesn't work because you're using a big character class; instead of trying to match the opposite, try to match what you don't want and then logically reverse that.
/^[-]{2} Select [-]{2}$/
function selectavalue() {
var selectBox = document.getElementById('selectboxid');
var user_input = selectBox.options[selectBox.selectedIndex].innerHTML;
var str = user_input;
if((str.match(/--Select--/i)) )
{
alert("Please select a value");
}
else
{
alert("The value u selected is"+str);
}
}
call this function from your selectbox.onchange="return selectavalue();"
You can use jQuery
if($("#id of your select box").attr("selectedIndex") == 0)
{
alert("You haven't selected anything!");
}
You have to make first value as default value.

assigning value in razor difficulty

I am having the following pice of code which is firing error
Error 1 Invalid expression term '='
#{
int Interest;
}
<td>#if (#item.interest.HasValue)
{
#Interest= #item.interest.Value.ToString("F2");
}
When declaring a variable, this variable needs to be assigned:
#{
string Interest = "";
}
and then:
#if (item.interest.HasValue)
{
Interest = item.interest.Value.ToString("F2");
}
This being said doing something like this in a view is a very bad design. I mean things like declaring and assigning variables based on some condition is not a logic that should be placed in a view. The view is there to display data. This logic should go to your controller or view model.
Inside your #if block you can address variables without the # sign.
#if (#item.interest.value) {
#item= #item.interest.Value
}
Is interpreted as:
#if (#item.interest.value) {
Write(item=);
Write(#item.interest.Value);
}
As you can see Write(item=) is not valid C# code.
You should use:
#if (item.interest.value) {
item = item.interest....
}
The reason your if (#item....) statement compiles, with the # sign. Is because you can prefix an identifier with the # to use reserved words as identifier names.
Try this:
#{
string Interest;
}
<td>#if (#item.interest.HasValue)
{
Interest= #item.interest.Value.ToString("F2");
}
By the way you are trying to assign a string (the result of ToString()) to an integer. This will not work.

how to break out of "if" block in VB.NET

How can I break out of an if statement?
Exit only works for "for", "sub", etc.
In VB.net:
if i > 0 then
do stuff here!
end if
In C#:
if (i > 0)
{
do stuff here!
}
You can't 'break out' of an if statement. If you are attempting this, your logic is wrong and you are approaching it from the wrong angle.
An example of what you are trying to achieve would help clarify, but I suspect you are structuring it incorrectly.
There isn't such an equivalent but you should't really need to with an If statement. You might want to look into using Select Case (VB) or Switch (C#) statements.
In C# .NET:
if (x > y)
{
if (x > z)
{
return;
}
Console.Writeline("cool");
}
Or you could use the goto statement.
You can use
bool result = false;
if (i < 10)
{
if (i == 7)
{
result = true;
break;
}
}
return result;
I have to admit, that in some cases you really wanna have something like an exit sub or a break. On a rare occasion is I use "Goto End" and jump over the "End If" with the def. End:
I know this is an old post but I have been looking for the same answer then eventually I figured it out
try{
if (i > 0) // the outer if condition
{
Console.WriteLine("Will work everytime");
if (i == 10)//inner if condition.when its true it will break out of the outer if condition
{
throw new Exception();
}
Console.WriteLine("Will only work when the inner if is not true");
}
}
catch (Exception ex)
{
// you can add something if you want
}
`

Flex datagrid universal numeric sorting function?

I am using a Flex dataGrid, and need to sort some of my columns numerically.
Looking at the sortCompareFunction, it seems like i need to create a different function for each column that i want to sort, because my sort function has to know what field it is sorting on.
Is there any way that I can pass the field to be sorted on into the function? so that I only need one numeric sorting function.
I did it using this function:
function fieldNumericSorter(field:String):Function {
return function (obj1:Object, obj2:Object):int {
return sign( int(obj1[field]) - int(obj2[field]) );
}
}
and for each column that needed sorting set
colToBeSorted.sortCompareFunction = fieldNumericSorter("fieldname");
If you are using a DataGrid with an XML dataProvider, this worked for me (modified from Alex's answer):
private function xmlDataGridNumericSorter(field:String):Function
{
return function (obj1:Object, obj2:Object):int
{
var num:Number = ((Number)(obj1.attribute(field)) - (Number)(obj2.attribute(field)));
return (num > 0) ? 1 : ((num < 0) ? -1 : 0);
}
}
and
dataGridColumn.sortCompareFunction = xmlDataGridNumericSorter(xmlAttribute.name().toString());
A very nice solution, considering how common a procedure this probably is..
Thanks Alex, hope this helps people further.
I did not use a numeric function to sort - instead did the following:
arrayCollObject.addItem({Col1: rowData[0], Col2: parseFloat(rowData[1])});
This seems to do the sorting correctly.

Resources