Nevron Open Vision Documentation
Row Values

 
About Row Values
Row values are attributes that derive from the base NRowValue class. The purpose of the row value attribute is to define a function that provides row value objects for a specific data source row. All values for rows provided by a NRowValue must be from a row value defined row value type. Row values are used in Row Conditions, Grouping Rules, Sorting Rules etc. Following are the currently supported row value types.
NFieldRowValue 
NFieldRowValue - this type of row value returns the value of a specific data source field as a value for the row. The field, whose value is provided needs to be specified by the user. The row value type associated with NFieldRowValue is the same as the field type from which this row value gets values. The following code snipped creates a grouping rule that groups the data by the Name field:

NFieldRowValue example
Copy Code
// create a view and get its grid
NTableGridView tableView = new NTableGridView();
NTableGrid tableGrid = tableView.Grid;
// group records by the Name field
NGroupingRule groupingRule = new NGroupingRule();
groupingRule.RowValue = new NFieldRowValue("Name");
tableGrid.GroupingRules.Add(groupingRule);
// create a view and get its grid
NTableGridView tableView = new NTableGridView();
NTableGrid tableGrid = tableView.Grid;
NColumnRowValue
NColumnRowValue - this type of row value returns the value provided by a specific column. If the column is a NDataColumn (i.e. column that displays a specific field from the data source), this condition is identical to the NFieldRowValue row value. The grid however can have calculated columns, that displays values that are provided by a user defined formula or user handled event, so this type of row value comes handy when you want to group or filter by calculated columns. The row value type associated with NColumnRowValue is provided by the column from which this row value gets values. The following code example defines a fictional calculated column and defines a column filter:
NColumnRowValue example
Copy Code
// create a view and get its grid
NTableGridView tableView = new NTableGridView();
NTableGrid tableGrid = tableView.Grid;
// bind to data source
NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo("Price", typeof(double)), new NFieldInfo("Quantity", typeof(int)));
dataTable.AddRow(20.0d, 4);
dataTable.AddRow(30.0d, 5);
tableGrid.DataSource = new NDataSource(dataTable);
// create a formula calculated column the value of which is Price * Quantity (i.e. Total)
NFormulaCalculatedColumn totalCalculatedColumn = new NFormulaCalculatedColumn();
string formula = tableGrid.CreateFormulaFieldName("Price") + "*" + tableGrid.CreateFormulaFieldName("Quantity");
totalCalculatedColumn.Formula = formula;
tableGrid.Columns.Add(totalCalculatedColumn);
// create a filter rule that only passes records for which the value of the calculated Total is greater than 100
NFilteringRule filteringRule = new NFilteringRule();
NOperatorRowCondition rowCondition = new NOperatorRowCondition();
rowCondition.RowValue = new NColumnRowValue(totalCalculatedColumn);
rowCondition.Operator = ENRowConditionOperator.GreaterThan;
rowCondition.Value = "100";
filteringRule.RowCondition = rowCondition;
tableGrid.FilteringRules.Add(filteringRule);
NCustomRowValue 

NCustomRowValue - a custom row returns a user provided value and is associated with an user provided row value type. You can use this row value to provide any custom row value that you want. The following code example defines a custom row value and a fictional filter.

NCustomRowValue example
Copy Code
// create a view and get its grid
NTableGridView tableView = new NTableGridView();
NTableGrid tableGrid = tableView.Grid;
// bind to data source
NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo("Price", typeof(double)), new NFieldInfo("Quantity", typeof(int)));
dataTable.AddRow(20.0d, 4);
dataTable.AddRow(30.0d, 5);
tableGrid.DataSource = new NDataSource(dataTable);
// create a custom row value that provides a total row value and use it in a filter
NCustomRowValue<double> customRowValue = new NCustomRowValue<double>();
customRowValue.GetRowValueDelegate = delegate(NCustomRowValueGetRowValueArgs<double> args)
{
    NDataSource dataSource = args.DataSource;
    return (double)((double)dataSource[args.Row, "Price"] * (int)dataSource[args.Row, "Quantity"]);
};
// create a filter rule that only passes records for which the value of the Total is greater than 100
NFilteringRule filteringRule = new NFilteringRule();
NOperatorRowCondition rowCondition = new NOperatorRowCondition();
rowCondition.RowValue = customRowValue;
rowCondition.Operator = ENRowConditionOperator.GreaterThan;
rowCondition.Value = "100";
filteringRule.RowCondition = rowCondition;
tableGrid.FilteringRules.Add(filteringRule);

See Also
Send Feedback