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() { m_TableView = new NTableGridView(); m_TableView.Grid.DataSource = NDummyDataSource.CreateCompanySalesDataSource(); m_TableView.Grid.AllowEdit = true; return(m_TableView); }
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; // bind to sales data source NDataSource dataSource = NDummyDataSource.CreateCompanySalesDataSource(); grid.DataSource = dataSource; // create an expression filter rule that matches records for which Company is equal to Leka string companyFxName = dataSource.CreateFormulaFieldName("Company"); string expression1 = companyFxName + "==\"" + NDummyDataSource.RandomCompanyName() + "\""; grid.FilteringRules.Add(new NFilteringRule(new NFormulaRowCondition(expression1))); // create an expression filter rule that matches records for which Sales is larger than 1000 string salesFxName = dataSource.CreateFormulaFieldName("Sales"); string expression2 = salesFxName + ">1000"; grid.FilteringRules.Add(new NFilteringRule(new NFormulaRowCondition(expression2))); grid.AllowSortColumns = true; grid.AlternatingRows = true; grid.RowHeaders.Visible = true; return(view); }
protected override NWidget CreateExampleContent() { m_GridView = new NTableGridView(); m_GridView.Grid.DataSource = NDummyDataSource.CreateProductsDataSource(); m_GridView.Grid.AllowSortColumns = 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() { m_TableView = new NTableGridView(); m_TableView.Grid.DataSource = NDummyDataSource.CreateCompanySalesDataSource(); // show the row headers m_TableView.Grid.RowHeaders.Visible = true; return(m_TableView); }
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_TableView = new NTableGridView(); // create a dummy data source with many columns to demonstrate horizontal scrolling NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { // person info new NFieldInfo("Name-0", typeof(String)), new NFieldInfo("Gender-1", typeof(ENGender)), new NFieldInfo("Birthday-2", typeof(DateTime)), new NFieldInfo("Phone-3", typeof(String)), new NFieldInfo("Email-4", typeof(String)), // address info new NFieldInfo("Country-5", typeof(ENCountry)), new NFieldInfo("City-6", typeof(String)), new NFieldInfo("Address-7", typeof(String)), // product info new NFieldInfo("Product Name-8", typeof(String)), new NFieldInfo("Product Price-9", typeof(Double)), new NFieldInfo("Product Quantity-10", typeof(Int32)), }); for (int i = 0; i < 1000; i++) { NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.RandomPersonInfo(); NDummyDataSource.NAddressInfo addressInfo = NDummyDataSource.RandomAddressInfo(); NDummyDataSource.NProductInfo productInfo = NDummyDataSource.RandomProductInfo(); dataTable.AddRow( // person info personInfo.Name, personInfo.Gender, personInfo.Birthday, personInfo.Phone, personInfo.Email, // address addressInfo.Country, addressInfo.City, addressInfo.Address, // product productInfo.Name, productInfo.Price, NDummyDataSource.RandomInt32(1, 100) ); } m_TableView.Grid.DataSource = new NDataSource(dataTable); return(m_TableView); }
/// <summary> /// Creates a fictional data source that represents received e-mails. /// </summary> /// <returns></returns> private NDataSource CreateMailDataSource() { // create a a dummy data table that represents a simple organization. NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { new NFieldInfo("From", typeof(String)), new NFieldInfo("Subject", typeof(String)), new NFieldInfo("Received", typeof(DateTime)), new NFieldInfo("Size", typeof(String)), }); string[] subjects = new string[] { "VIVACOM BILL", "SharePoint Users", "USB Sticks", "Garden Conference", ".NET Core and .NET Native", "Hackers Attack", "Week in Review", "Big Data Analytics", "Encryption Compromise", "Grid Issues", "DSC SOT BILL", "Data Security Bulletin", "How Cybercriminals use Facebook", "Empowering Users Success", "Boost your Income", "The AMISH way to motivate", "Daily news", }; Random rnd = new Random(); for (int i = 0; i < 600; i++) { string name = NDummyDataSource.RandomPersonInfo().Name; string subject = subjects[rnd.Next(subjects.Length)]; DateTime received = m_Now - new TimeSpan(rnd.Next(60), rnd.Next(24), rnd.Next(60), 0); string size = (10 + rnd.Next(100)).ToString() + " KB"; dataTable.AddRow(name, subject, received, size); } return(new NDataSource(dataTable)); }
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.CreateCompanySalesDataSource(); // create a sorting rule that sorts by the company column first NColumn companyColumn = grid.Columns.GetColumnByFieldName("Company"); grid.SortingRules.Add(new NSortingRule(companyColumn, ENSortingDirection.Ascending)); // create a sorting rule that sorts by the sales column next NColumn salesColumn = grid.Columns.GetColumnByFieldName("Sales"); grid.SortingRules.Add(new NSortingRule(salesColumn, ENSortingDirection.Ascending)); return(view); }
protected override NWidget CreateExampleContent() { NTableGridView gridView = new NTableGridView(); NTableGrid grid = gridView.Grid; // bind the grid to the data source grid.DataSource = NDummyDataSource.CreateCompanySalesDataSource(); // create a grouping rule that groups by the company field value first // note that in order to indicate the grouping in the grouping panel, the rule must reference the respective column NColumn companyColumn = grid.Columns.GetColumnByFieldName("Company"); string fx1 = grid.CreateFormulaFieldName("Company"); NFormulaRowValue fxRowValue = new NFormulaRowValue(fx1); NGroupingRule groupingRule1 = new NGroupingRule(companyColumn, fxRowValue, ENSortingDirection.Ascending); grid.GroupingRules.Add(groupingRule1); // create a grouping rule that groups by sales larger than 1000 next // note that in order to indicate the grouping in the grouping panel, the rule must reference the respective column string fx2 = grid.CreateFormulaFieldName("Sales") + ">1000"; NColumn salesColumn = grid.Columns.GetColumnByFieldName("Sales"); NGroupingRule groupingRule2 = NGroupingRule.FromFormula(salesColumn, fx2); groupingRule2.CreateGroupRowCellsDelegate += delegate(NGroupingRuleCreateGroupRowCellsArgs arg) { bool groupValue = (bool)((NVariant)arg.GroupRow.GroupValue); string text = groupValue? "Sales greater than 1000" : "Sales less than or equal to 1000"; return(new NGroupRowCell[] { new NGroupRowCell(text) }); }; grid.GroupingRules.Add(groupingRule2); // alter some view preferences grid.AllowSortColumns = true; grid.AlternatingRows = true; grid.RowHeaders.Visible = true; return(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() { NMemoryDataTable dataTable = new NMemoryDataTable( new NFieldInfo("Company", typeof(String)), new NFieldInfo("RegionSales", typeof(Double[]))); Random rnd = new Random(); for (int i = 0; i < 1000; i++) { Double[] arr = new Double[10]; for (int j = 0; j < 10; j++) { arr[j] = rnd.Next(100); } dataTable.AddRow(NDummyDataSource.RandomCompanyName(), arr); } // create a view and get its grid NTableGridView view = new NTableGridView(); NTableGrid grid = view.Grid; grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg) { if (arg.DataColumn.FieldName == "RegionSales") { NCustomColumnFormat pieColumnFormat = new NCustomColumnFormat(); pieColumnFormat.FormatDefaultDataCellDelegate = delegate(NDataCell theDataCell) { NWidget widget = new NWidget(); widget.PreferredSize = new NSize(400, 300); }; pieColumnFormat.CreateValueDataCellViewDelegate = delegate(NDataCell theDataCell, object value) { double[] values = (double[])value; NChartView chartView = new NChartView(); chartView.PreferredSize = new NSize(300, 60); NCartesianChart cartesianChart = new NCartesianChart(); NDockLayout.SetDockArea(cartesianChart, ENDockArea.Center); chartView.Surface.Content = cartesianChart; cartesianChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear); cartesianChart.Legend = null; cartesianChart.Axes[ENCartesianAxis.PrimaryX].Visible = false; NCartesianAxis yAxis = cartesianChart.Axes[ENCartesianAxis.PrimaryY]; NValueScaleLabelStyle labelStyle = new NValueScaleLabelStyle(); labelStyle.TextStyle.Font = new NFont("Arimo", 8); ((NLinearScale)yAxis.Scale).Labels.Style = labelStyle; NBarSeries barSeries = new NBarSeries(); barSeries.DataLabelStyle = new NDataLabelStyle(false); barSeries.InflateMargins = false; cartesianChart.Series.Add(barSeries); int count = values.Length; for (int i = 0; i < count; i++) { barSeries.DataPoints.Add(new NBarDataPoint(values[i])); } return(chartView); }; arg.DataColumn.Format = pieColumnFormat; } }; grid.DataSource = new NDataSource(dataTable); return(view); }
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 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, theColumn.Title, ENPairBoxRelation.Box1BeforeBox2); pairBox.Spacing = 2; return(pairBox); }; dataColumn.UpdateHeaderContent(); } // create the custom detail that creates a widget displaying information about the row. // NOTE: The widget is created by the OnCustomDetailCreateWidget event handler. NMasterDetails masterDetails = grid.MasterDetails; NCustomDetail customDetail = new NCustomDetail(); masterDetails.Details.Add(customDetail); customDetail.CreateWidgetDelegate = delegate(NCustomDetailCreateWidgetArgs arg) { // get information about the data source row string name = (string)arg.DataSource.GetValue(arg.RowIndex, "Name"); ENGender gender = (ENGender)arg.DataSource.GetValue(arg.RowIndex, "Gender"); DateTime birthday = (DateTime)arg.DataSource.GetValue(arg.RowIndex, "Birthday"); ENCountry country = (ENCountry)arg.DataSource.GetValue(arg.RowIndex, "Country"); string phone = (string)arg.DataSource.GetValue(arg.RowIndex, "Phone"); string email = (string)arg.DataSource.GetValue(arg.RowIndex, "Email"); // display the information as a widget NPairBox namePair = new NPairBox("Name:", name); NPairBox genderPair = new NPairBox("Gender:", gender.ToString()); NPairBox birthdayPair = new NPairBox("Birthday:", birthday.ToString()); NPairBox countryPair = new NPairBox("Country:", country.ToString()); NPairBox phonePair = new NPairBox("Phone:", phone.ToString()); NPairBox emailPair = new NPairBox("Email:", email.ToString()); NImageBox image = new NImageBox(); switch (gender) { case ENGender.Male: image.Image = Nevron.Nov.Examples.NResources.Image__256x256_MaleIcon_jpg; break; case ENGender.Female: image.Image = Nevron.Nov.Examples.NResources.Image__256x256_FemaleIcon_jpg; break; default: break; } NStackPanel infoStack = new NStackPanel(); infoStack.VerticalSpacing = 2.0d; infoStack.Add(namePair); infoStack.Add(genderPair); infoStack.Add(birthdayPair); infoStack.Add(countryPair); infoStack.Add(phonePair); infoStack.Add(emailPair); NDockPanel dock = new NDockPanel(); dock.Add(image, ENDockArea.Left); dock.Add(infoStack, ENDockArea.Center); // assign the widget to the event arguments. return(dock); }; return(m_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); }
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() { m_TableView = new NTableGridView(); m_TableView.Grid.DataSource = NDummyDataSource.CreatePersonsDataSource(); return(m_TableView); }