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 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 - 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); |