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() { 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); }