protected override NWidget CreateExampleContent() { // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; grid.AllowEdit = true; // create persons order data source NDataSource personOrders = NDummyDataSource.CreatePersonsOrdersDataSource(); // get the min and max price. We will use it in the progress bars. object min, max; personOrders.TryGetMin("Price", out min); personOrders.TryGetMax("Price", out max); grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs args) { if (args.FieldInfo.Name == "Price") { // create a progress bar column format for the Price field NSliderColumnEditor sliderColumnEditor = new NSliderColumnEditor(); args.DataColumn.Editor = sliderColumnEditor; args.DataColumn.WidthMode = ENColumnWidthMode.Fixed; args.DataColumn.FixedWidth = 150; } }; grid.DataSource = personOrders; return(view); }
protected override NWidget CreateExampleContent() { // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // create persons order data source NDataSource personOrders = NDummyDataSource.CreatePersonsOrdersDataSource(); // get the min and max price. We will use it in the progress bars. object min, max; personOrders.TryGetMin("Price", out min); personOrders.TryGetMax("Price", out max); grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs args) { if (args.FieldInfo.Name == "Price") { // create a progress bar column format for the Price field NProgressBarColumnFormat progressBarColumnFormat = new NProgressBarColumnFormat(); progressBarColumnFormat.Minimum = Convert.ToDouble(min); progressBarColumnFormat.Maximum = Convert.ToDouble(max); args.DataColumn.Format = progressBarColumnFormat; } }; grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); return(view); }
protected override NWidget CreateExampleContent() { m_GridView = new NTableGridView(); m_GridView.Grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // create a total column that is pinned to the right // add an event calculated column of type Double NCustomCalculatedColumn <Double> totalColumn = new NCustomCalculatedColumn <Double>(); totalColumn.Title = "Total"; totalColumn.FreezeMode = ENColumnFreezeMode.Right; totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg) { // calculate a RowValue for the RowIndex double price = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price")); double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity")); return((double)(price * quantity)); }; totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell); m_GridView.Grid.Columns.Add(totalColumn); // freeze the pruduct name to the left NColumn productNameColumn = m_GridView.Grid.Columns.GetColumnByFieldName("Product Name"); productNameColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell); productNameColumn.FreezeMode = ENColumnFreezeMode.Left; return(m_GridView); }
protected override NWidget CreateExampleContent() { m_GridView = new NTableGridView(); m_GridView.Grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); m_GridView.Grid.AlternatingRows = true; return(m_GridView); }
protected override NWidget CreateExampleContent() { // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // customize the grid grid.AllowEdit = false; // create the dummy persons data source - we will use it to obtain person names from person ids from it. m_PersonsDataSource = NDummyDataSource.CreatePersonsDataSource(); // bind to data source, but exclude the "PersonId" field from binding grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg) { if (arg.FieldInfo.Name == "PersonId") { arg.DataColumn = null; } }; grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // create a grouping rule that groups by the PersonId field NGroupingRule groupingRule = new NGroupingRule(); groupingRule.RowValue = new NFieldRowValue("PersonId"); // create a custom grouping header named "Person" groupingRule.CreateGroupingHeaderContentDelegate = delegate(NGroupingRule theGroupingRule) { return(new NLabel("Person")); }; // create custom group row cells that display the person Name and number of orders groupingRule.CreateGroupRowCellsDelegate = delegate(NGroupingRuleCreateGroupRowCellsArgs arg) { // get the person id from the row for which we create row cells. int personId = (int)arg.GroupRow.GroupValue; // get the person name that corresponds to that person id. int idField = m_PersonsDataSource.GetFieldIndex("Id"); NRecordset rs = m_PersonsDataSource.GetOrCreateIndex(idField).GetRecordsForValue(personId); string personName = (string)m_PersonsDataSource.GetValue(rs[0], "Name"); // create the group row cells NGroupRowCell personNameCell = new NGroupRowCell(personName); personNameCell.EndXPosition.Mode = ENSpanCellEndXPositionMode.NextCellBeginX; NGroupRowCell ordersCountCell = new NGroupRowCell("Orders Count:" + arg.GroupRow.Recordset.Count); ordersCountCell.EndXPosition.Mode = ENSpanCellEndXPositionMode.RowEndX; ordersCountCell.BeginXPosition.Mode = ENSpanCellBeginXPositionMode.AnchorToEndX; return(new NGroupRowCell[] { personNameCell, ordersCountCell }); }; grid.GroupingRules.Add(groupingRule); return(view); }
protected override NWidget CreateExampleContent() { NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // bind the grid to the data source, but exclude the "PersonId" column. grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg) { if (arg.FieldInfo.Name == "PersonId") { arg.DataColumn = null; } }; grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // add a custom calculated column of type Double that displays the Total (e.g. Price * Quantity) NCustomCalculatedColumn <double> totalColumn = new NCustomCalculatedColumn <double>(); totalColumn.Title = "Total"; totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg) { // calculate a RowValue for the RowIndex double price = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price")); double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity")); return((double)(price * quantity)); }; totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell); grid.Columns.Add(totalColumn); // show only records where PersonId = "0" // NOTE: when the rule is not associated with a column, you must explicitly specify a row value for the row condition. NFilteringRule personIdFilterRule = new NFilteringRule(); NOperatorRowCondition rowCondition = new NOperatorRowCondition(ENRowConditionOperator.Equals, "0"); rowCondition.RowValue = new NFieldRowValue("PersonId"); personIdFilterRule.RowCondition = rowCondition; grid.FilteringRules.Add(personIdFilterRule); // show only records for which the total column is larger than 150 // NOTE: when the rule is associated with a column, by default the row condition operates on the column values. NFilteringRule companyFilterRule = new NFilteringRule(); companyFilterRule.Column = totalColumn; companyFilterRule.RowCondition = new NOperatorRowCondition(ENRowConditionOperator.GreaterThan, "150"); grid.FilteringRules.Add(companyFilterRule); // customize the grid grid.AllowSortColumns = true; grid.AlternatingRows = true; grid.RowHeaders.Visible = true; return(view); }
protected override NWidget CreateExampleContent() { m_GridView = new NTableGridView(); NTableGrid grid = m_GridView.Grid; // bind the grid to the data source grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // add a formula column m_TotalColumn = new NFormulaCalculatedColumn(); m_TotalColumn.Title = "Total"; string fx = grid.CreateFormulaFieldName("Price") + "*" + grid.CreateFormulaFieldName("Quantity"); m_TotalColumn.Formula = fx; m_TotalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell); grid.Columns.Add(m_TotalColumn); return(m_GridView); }
protected override NWidget CreateExampleContent() { // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // bind the grid to the data source grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // add a custom calculated column of type Double that displays the Total (e.g. Price * Quantity) NCustomCalculatedColumn <double> totalColumn = new NCustomCalculatedColumn <double>(); totalColumn.Title = "Total"; totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg) { // calculate a RowValue for the RowIndex double price = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price")); double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity")); return((double)(price * quantity)); }; totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell); grid.Columns.Add(totalColumn); // create the sales sorting rule. // also subcribe for the create sorting rule event to recreate the rule when users grid.SortingRules.Add(CreateTotalSortingRule(grid)); totalColumn.CreateSortingRuleDelegate = delegate(NColumn theColumn) { return(CreateTotalSortingRule(grid)); }; // alter some view preferences grid.AllowSortColumns = true; grid.AlternatingRows = true; grid.RowHeaders.Visible = true; return(view); }
protected override NWidget CreateExampleContent() { m_GridView = new NTableGridView(); NTableGrid grid = m_GridView.Grid; // bind the grid to the data source grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // add an event calculated column of type Double NCustomCalculatedColumn <Double> totalColumn = new NCustomCalculatedColumn <Double>(); totalColumn.Title = "Total"; totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg) { // calculate a RowValue for the RowIndex double price = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price")); double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity")); return((double)(price * quantity)); }; totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell); grid.Columns.Add(totalColumn); return(m_GridView); }
protected override NWidget CreateExampleContent() { // create a view and get its grid m_View = new NTableGridView(); NTableGrid grid = m_View.Grid; // bind the grid to the data source grid.DataSource = NDummyDataSource.CreatePersonsDataSource(); // configure the master grid grid.AllowEdit = false; // assign some icons to the columns for (int i = 0; i < grid.Columns.Count; i++) { NDataColumn dataColumn = grid.Columns[i] as NDataColumn; if (dataColumn == null) { continue; } NImage image = null; switch (dataColumn.FieldName) { case "Name": image = NResources.Image__16x16_Contacts_png; break; case "Gender": image = NResources.Image__16x16_Gender_png; break; case "Birthday": image = NResources.Image__16x16_Birthday_png; break; case "Country": image = NResources.Image__16x16_Globe_png; break; case "Phone": image = NResources.Image__16x16_Phone_png; break; case "Email": image = NResources.Image__16x16_Mail_png; break; default: continue; } // NOTE: The CreateHeaderContentDelegate is invoked whenever the Title changes or the UpdateHeaderContent() is called. // you can use this event to create custom column header content dataColumn.CreateHeaderContentDelegate = delegate(NColumn theColumn) { NPairBox pairBox = new NPairBox(image, dataColumn.Title, ENPairBoxRelation.Box1BeforeBox2); pairBox.Spacing = 2; return(pairBox); }; dataColumn.UpdateHeaderContent(); } // get the grid master details NMasterDetails masterDetails = grid.MasterDetails; // creater the table grid detail. // NOTE: It shows information from the sales data source. the details are bound using field binding NTableGridDetail detail = new NTableGridDetail(); masterDetails.Details.Add(detail); detail.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // configure the details grid detail.GridView.Grid.AllowEdit = false; NRelationMasterBinding masterBinding = new NRelationMasterBinding(); masterBinding.Relations.Add(new NRelation("Id", "PersonId")); detail.MasterBinding = masterBinding; return(m_View); }
protected override NWidget CreateExampleContent() { // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // customize the grid grid.AllowEdit = false; // bind to data source, but exclude the "PersonId" field from binding grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg) { if (arg.FieldInfo.Name == "PersonId") { arg.DataColumn = null; } }; grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // create a calculated Total column NCustomCalculatedColumn <double> totalColumn = new NCustomCalculatedColumn <double>(); totalColumn.Title = "Total"; totalColumn.GetRowValueDelegate = delegate(NCustomCalculatedColumnGetRowValueArgs <double> args) { double price = Convert.ToDouble(args.DataSource.GetValue(args.RowIndex, "Price")); int quantity = Convert.ToInt32(args.DataSource.GetValue(args.RowIndex, "Quantity")); return((double)(price * quantity)); }; grid.Columns.Add(totalColumn); // create a grouping rule that groups by the Product Name column NGroupingRule groupingRule = new NGroupingRule(grid.Columns.GetColumnByFieldName("Product Name")); // create a footer summary row for the total total groupingRule.CreateFooterSummaryRowsDelegate = delegate(NGroupingRuleCreateSummaryRowsArgs args) { // get the recordset for the group NRecordset recordset = args.GroupRow.Recordset; // calculate the sum of totals double total = 0; for (int i = 0; i < recordset.Count; i++) { total += Convert.ToDouble(totalColumn.GetRowValue(recordset[i])); } // create the total summary row NSummaryRow totalRow = new NSummaryRow(); totalRow.Cells = new NSummaryCellCollection(); NSummaryCell cell = new NSummaryCell(); cell.BeginXPosition.Mode = ENSpanCellBeginXPositionMode.AnchorToEndX; cell.EndXPosition.Mode = ENSpanCellEndXPositionMode.RowEndX; cell.Content = new NLabel("Grand Total: " + total.ToString("0.00")); totalRow.Cells.Add(cell); return(new NSummaryRow[] { totalRow }); }; grid.GroupingRules.Add(groupingRule); return(view); }
protected override NWidget CreateExampleContent() { // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; // bind the grid to the PersonsOrders data source grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource(); // Formatting Rule 1 = applied to the Product Name column. // make the Aptax, Joykix, Zun Zimtam, Dingtincof cell backgrounds LightCoral, with a bold Font { // create the formatting rule and add it in the "Product Name" column NColumn column = grid.Columns.GetColumnByFieldName("Product Name"); NFormattingRule formattingRule = new NFormattingRule(); column.FormattingRules.Add(formattingRule); // row condition NOrGroupRowCondition orCondition = new NOrGroupRowCondition(); orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Aptax")); orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Joykix")); orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Zun Zimtam")); orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Dingtincof")); formattingRule.RowCondition = orCondition; // LightCoral background fill declaration NBackgroundFillDeclaration backgroundFillDeclaration = new NBackgroundFillDeclaration(); backgroundFillDeclaration.Mode = ENFillDeclarationMode.Uniform; backgroundFillDeclaration.UniformFill = new NColorFill(NColor.LightCoral); formattingRule.Declarations.Add(backgroundFillDeclaration); // Bold font style declaration NFontStyleDeclaration fontStyleDeclaration = new NFontStyleDeclaration(); fontStyleDeclaration.FontStyle = ENFontStyle.Bold; formattingRule.Declarations.Add(fontStyleDeclaration); } // Formatting Rule 2 = applied to the Product Name column. // make the Aptax and Joykix cell backgrounds LightCoral, with a bold Font { // create the formatting rule and add it in the "Product Name" column NColumn column = grid.Columns.GetColumnByFieldName("Price"); NFormattingRule formattingRule = new NFormattingRule(); column.FormattingRules.Add(formattingRule); // row condition formattingRule.RowCondition = new NTrueRowCondition(); // get price field min and max object minPrice, maxPrice; int priceFieldIndex = grid.DataSource.GetFieldIndex("Price"); grid.DataSource.TryGetMin(priceFieldIndex, out minPrice); grid.DataSource.TryGetMax(priceFieldIndex, out maxPrice); // make a graident fill declaration NBackgroundFillDeclaration backgroundFillDeclaration = new NBackgroundFillDeclaration(); backgroundFillDeclaration.Mode = ENFillDeclarationMode.TwoColorGradient; backgroundFillDeclaration.MinimumValue = Convert.ToDouble(minPrice); backgroundFillDeclaration.MaximumValue = Convert.ToDouble(maxPrice); backgroundFillDeclaration.BeginColor = NColor.Green; backgroundFillDeclaration.EndColor = NColor.Red; formattingRule.Declarations.Add(backgroundFillDeclaration); } return(view); }