Page 1 of 1
Row_rendered server event
Posted: Tue Feb 23, 2016 1:07 am
by ashworth81
Hi,
trying to amend row attributes based on values.
Noticed this in the help file...
// Change the row color in List page
if (ew_SameStr(Trademark.ViewValue, "BMW"))
RowAttrs["style"] = "color: red; background-color: #ccffcc";
How can I amend this code for when I have 2 conditions and one of the conditions is a 'if greater than' statement.
I need something like...
if (Trademark.ViewValue == "BMW") && (qty.ViewValue > "1000")
RowAttrs["style"] = "color: red; background-color: #ccffcc";
I have searched the forum and googled for hours. Cannot find the answer. Please help.
Re: Row_rendered server event
Posted: Tue Feb 23, 2016 11:49 am
by motfs
You need to convert the string value to number or integer in order to use ">", such as ew_ConvertToInt().
Re: Row_rendered server event
Posted: Tue Mar 15, 2016 12:47 am
by ashworth81
Hi Mofts,
thanks for your reply.
I have managed to get the first part working with:
// Row Inserted event
public void Row_Inserted(OrderedDictionary rsold, OrderedDictionary rsnew) {
//ew_Write("Row Inserted");
if (Convert.ToInt32(rsnew["Total Weight kg"]) > 1200)
SuccessMessage = "Warning: The total weight is over 1200kg ";
}
This works correctly.
I am struggling to add a second argument to the statement. I need as below...
// Row Inserted event
public void Row_Inserted(OrderedDictionary rsold, OrderedDictionary rsnew) {
//ew_Write("Row Inserted");
if (Convert.ToInt32(rsnew["Total Weight kg"]) > 1200) && ((rsnew["Haulier"]) == "2")
SuccessMessage = "Warning: The total weight is over 1200kg ";
}
I receive an error "Invalid expression term '&&'"
Any idea how I can add the second clause?
Re: Row_rendered server event
Posted: Tue Mar 15, 2016 12:04 pm
by motfs
if (Convert.ToInt32(rsnew["Total Weight kg"]) > 1200) && ((rsnew["Haulier"]) == "2")
You miss "(" ")". The correct code is:
if (condition1 && condition2)
...