Row conditions are attributes that derive from the base NRowCondition class. The purpose of the row condition attribute is to define a predicate that specifies whether a certain row satisfies the condition or not. Row conditions are used in Filters, Conditional Formatting etc. All conditions have the ability to be inverted, which is specified by the NRowCondition.Inverted property.
Following are the currently supported types of row conditions:
The operator row condition is probably the most widely used row condition. It defines an operator based predicate, with a static right hand operand, the value of which is defined by the
Value property. The left hand operand is the current row value, provided by a
NRowValue attribute (see
Row Values for more info). The
Value property is defined as a string that needs to be a parsable by the respective
row value type. The operator is defined by the
Operator property, that takes values from the
ENRowConditionOperator enumeration:
Equals - Returns true, if the current row value is Equal to the Value.
LessThan - Returns true, if the current row value is Less Than the Value.
GreaterThan - Returns true, if the current row value is Greater Than the Value.
LessThanOrEqualTo - Returns true, if the current row value is Less Than Or Equal to the Value
GreaterThanOrEqualTo - Returns true, if the current row value is Greater Than Or Equal to the Value
StartsWith - Returns true, if the string representation of the row value begins with the specified Value
EndsWith - Returns true, if the string representation of the row value ends with the specified value
Contains - Returns true, if the string representation of the row value contains the specified value
ContainedIn - Returns true, if the string representation of the row value is contained in the specified value
Like - Returns true, if the string representation of the row value is like the specified regular expression
IsEmpty - Returns true, if the string representation of the row value is empty (string of zero length)
IsNull - Returns true, if the row value is null
The following code example creates a filter rule with an operator row condition that passes row values for which the Sales field is
greater than 100:
NOperatorRowCondition example |
Copy Code
|
NFilteringRule filteringRule = new NFilteringRule();
NOperatorRowCondition rowCondition = new NOperatorRowCondition();
rowCondition.RowValue = new NFieldRowValue("Sales");
rowCondition.Operator = ENRowConditionOperator.GreaterThan;
rowCondition.Value = "100";
filteringRule.RowCondition = rowCondition;
grid.FilteringRules.Add(filteringRule);
|
This is a very fast row condition and should be used with priority over the
NFormulaRowCondition when possible.
The formula row condition defines a formula that is evaluated for each row. It is a user responsibility to author such a formula that evaluates to a boolean value (i.e. true or false). See Formulas Overview for more information about formulas. Also take a look at the Formulas in Grids for a discussion about the variables you can use in formula. The following code example creates a formula row condition used in a filtering rule, that passes rows for which the Sales field is greater than 100:
NFormulaRowCondition |
Copy Code
|
NFilteringRule filteringRule = new NFilteringRule();
NFormulaRowCondition rowCondition = new NFormulaRowCondition();
rowCondition.Formula = tableGrid.CreateFormulaFieldName("Sales") + ">100";
filteringRule.RowCondition = rowCondition;
grid.FilteringRules.Add(filteringRule);
|
The NFormulaRowCondtion is a very versatile row condition that can utilize the full power of NOV Formulas, however when possible it is recommended to use the NOperatorRowCondtion because of its superior performance.
The custom row condition is defined by the user. It is a user responsibility to provide a custom predicate that returns true or false, depending on whether the specified row passes the condition or not. The following code example creates a custom row condition used in a filtering rule, that passes rows for which the Sales field is greater than 100:
NCustomRowCondition |
Copy Code
|
NFilteringRule filteringRule = new NFilteringRule();
NCustomRowCondition rowCondition = new NCustomRowCondition();
rowCondition.RowPredicateDelegate = delegate(NCustomRowConditionRowPredicateArgs args) {
double sales = Convert.ToDouble(args.DataSource[args.Row, "Sales"]);
return sales > 1000;
};
grid.FilteringRules.Add(filteringRule);
|
The AND group row condition is a composite condition, that aggregates other row condition. The row condition matches a specific row, if all aggregated conditions match the row. The following code example creates a filter rule that passes rows for which the Sales field is greater than 100 AND less than 200:
NAndGroupRowCondition |
Copy Code
|
NFilteringRule filteringRule = new NFilteringRule();
NAndGroupRowCondition rowCondition =new NAndGroupRowCondition();
rowCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Sales"), ENRowConditionOperator.GreaterThan, "100"));
rowCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Sales"), ENRowConditionOperator.LessThan, "200"));
filteringRule.RowCondition = rowCondition;
grid.FilteringRules.Add(filteringRule);
|
The OR group row condition is a composite condition, that aggregates other row condition. The row condition matches a specific row, if at least one aggregated condition match the row. The following code example creates a filter rule that passes rows for which the Sales field is
less than 100 OR greater than 200:
NOrGroupRowCondition |
Copy Code
|
NFilteringRule filteringRule = new NFilteringRule();
NOrGroupRowCondition rowCondition = new NOrGroupRowCondition();
rowCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Sales"), ENRowConditionOperator.LessThan, "100"));
rowCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Sales"), ENRowConditionOperator.GreaterThan, "200"));
filteringRule.RowCondition = rowCondition;
grid.FilteringRules.Add(filteringRule);
|
This a row condition that matches all rows. It is predicate that returns true for all rows.
This a row condition that does not match any row. It is predicate that returns false for all rows.