/// <summary> /// Sets the sample customization settings. /// </summary> private void SampleCustomization() { this.sfDataGrid1.AllowGrouping = true; this.sfDataGrid1.ShowGroupDropArea = true; this.sfDataGrid1.AutoGenerateColumns = false; this.sfDataGrid1.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalDigits = 0; nfi.NumberGroupSizes = new int[] { }; OrderInfoRepository orderInfo = new OrderInfoRepository(); this.sfDataGrid1.DataSource = orderInfo.GetOrdersDetails(30); this.sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "OrderID", HeaderText = "Order ID", NumberFormatInfo = nfi }); this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "CustomerID", HeaderText = "Customer ID" }); this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "ShipCity", HeaderText = "Ship City" }); this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "ShipCity", HeaderText = "Ship Country" }); this.sfDataGrid1.Columns.Add(new GridDateTimeColumn() { MappingName = "ShippingDate", HeaderText = "Shipping Date" }); this.sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "Freight", HeaderText = "Freight", FormatMode = FormatMode.Currency }); this.sfDataGrid1.Columns.Add(new GridCheckBoxColumn() { MappingName = "IsClosed", HeaderText = "Is Closed" }); #region Relation Creation GridViewDefinition viewDefinition = new GridViewDefinition(); viewDefinition.RelationalColumn = "OrderDetails"; SfDataGrid firstLevelSourceDataGrid = new SfDataGrid(); firstLevelSourceDataGrid.RowHeight = 21; firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "OrderID", HeaderText = "Order ID", NumberFormatInfo = nfi }); firstLevelSourceDataGrid.Columns.Add(new GridDateTimeColumn() { MappingName = "OrderDate", HeaderText = "Order Date" }); firstLevelSourceDataGrid.Columns.Add(new GridTextColumn() { MappingName = "CustomerID", HeaderText = "Customer ID" }); firstLevelSourceDataGrid.Columns.Add(new GridTextColumn() { MappingName = "CustomerCity", HeaderText = "Customer City" }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "ProductID", HeaderText = "Product ID", FormatMode = FormatMode.Numeric, NumberFormatInfo = nfi }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "UnitPrice", HeaderText = "Unit Price", FormatMode = FormatMode.Currency }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "Quantity", HeaderText = "Quantity", FormatMode = FormatMode.Numeric }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "Discount", HeaderText = "Discount", FormatMode = FormatMode.Percent }); StackedHeaderRow stackedHeaderRow = new StackedHeaderRow(); stackedHeaderRow.StackedColumns.Add(new StackedColumn() { ChildColumns = "OrderID,OrderDate", HeaderText = "Order Details" }); stackedHeaderRow.StackedColumns.Add(new StackedColumn() { ChildColumns = "CustomerID,CustomerCity", HeaderText = "Customer Details" }); stackedHeaderRow.StackedColumns.Add(new StackedColumn() { ChildColumns = "ProductID,UnitPrice,Quantity,Discount", HeaderText = "Product Details" }); firstLevelSourceDataGrid.StackedHeaderRows.Add(stackedHeaderRow); firstLevelSourceDataGrid.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill; viewDefinition.DataGrid = firstLevelSourceDataGrid; this.sfDataGrid1.DetailsViewDefinitions.Add(viewDefinition); #endregion this.sfDataGrid1.HideEmptyGridViewDefinition = true; }