示例#1
0
        /// <summary>
        /// Load the form for Create a Nested Table
        /// </summary>
        private void Form1_Load(object sender, System.EventArgs e)
        {
            DataTable parentTable     = GetParentTable();
            DataTable childTable      = GetChildTable();
            DataTable grandChildTable = GetGrandChildTable();

            // Manually specify relations in grouping engine. The DataSet does not need to have any DataRelations.
            // This is the same approach that should be used if you want to set up relation ships
            // between independent IList.
            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();

            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";    // same as SourceListSetEntry.Name for childTable (see below)
            parentToChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            parentToChildRelationDescriptor.RelationKeys.Add("Parent ID", "ParentID");

            // Add relation to ParentTable
            gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();

            childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";  // same as SourceListSetEntry.Name for grandChhildTable (see below)
            childToGrandChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            childToGrandChildRelationDescriptor.RelationKeys.Add("Child ID", "ChildID");

            // Add relation to ChildTable
            parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);


            // Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);

            this.gridGroupingControl1.DataSource = parentTable;

            this.gridGroupingControl1.TableOptions.ShowRowHeader = false;
            this.gridGroupingControl1.GetTableDescriptor("MyChildTable").TableOptions.ShowTableIndent = false;
            this.gridGroupingControl1.Appearance.RecordPlusMinusCell.Themed        = false;
            this.gridGroupingControl1.Appearance.RecordPlusMinusCell.BorderMargins = new Syncfusion.Windows.Forms.Grid.GridMarginsInfo(3, 3, 3, 3);

            this.gridGroupingControl1.Table.ExpandAllRecords();
        }
示例#2
0
        /// <summary>
        /// Helps to setup RelationKind.ForeignKeyReference relation .
        /// </summary>
        private void SampleCustomization()
        {
            gridGroupingControl1.DataSource = null;
            gridGroupingControl1.DataMember = "";

            gridGroupingControl1.TableDescriptor.Relations.Clear();

            this.gridGroupingControl1.Engine.SourceListSet.Add("Countries", countries.DefaultView);
            this.gridGroupingControl1.Engine.SourceListSet.Add("USStates", usStates.DefaultView);

            GridTableDescriptor mainTd = this.gridGroupingControl1.TableDescriptor;


            GridRelationDescriptor usStatesRd = new GridRelationDescriptor();

            usStatesRd.Name           = "State";
            usStatesRd.RelationKind   = RelationKind.ForeignKeyReference;
            usStatesRd.ChildTableName = "USStates";  // SourceListSet name for lookup
            usStatesRd.RelationKeys.Add("State", "Key");
            usStatesRd.ChildTableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.FromArgb(255, 245, 227);
            //usStatesRd.ChildTableDescriptor.VisibleColumns.Add("Name");
            usStatesRd.ChildTableDescriptor.SortedColumns.Add("Name");
            usStatesRd.ChildTableDescriptor.AllowEdit = false;
            usStatesRd.ChildTableDescriptor.AllowNew  = false; // Make pencil icon disappear, users can't modify states.
            mainTd.Relations.Add(usStatesRd);

            GridRelationDescriptor countriesRd = new GridRelationDescriptor();

            countriesRd.RelationKind   = RelationKind.ForeignKeyReference;
            countriesRd.ChildTableName = "Countries";  // SourceListSet name for lookup
            countriesRd.RelationKeys.Add("Country", "CountryCode");
            countriesRd.ChildTableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.FromArgb(255, 245, 227);
            countriesRd.ChildTableDescriptor.AllowEdit = true;
            countriesRd.ChildTableDescriptor.AllowNew  = true; // Make pencil icon appear, allow user to add countries (these setting will be overriden by CountriesCollection.IsReadOnly / CountriesCollection.IsFixedSize properties if they are true).
            mainTd.Relations.Add(countriesRd);

            gridGroupingControl1.DataSource = CreateMainTable();
            this.gridGroupingControl1.TableControl.DpiAware = true;
        }
示例#3
0
        void InitializeDataSet()
        {
            DataTable parentTable     = GetParentTable();
            DataTable childTable      = GetChildTable();
            DataTable grandChildTable = GetGrandChildTable();
            // Manually specify relations in grouping engine. The DataSet does not need to have any DataRelations.
            // This is the same approach that should be used if you want to set up relation ships
            // between independent IList.
            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();

            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";    // same as SourceListSetEntry.Name for childTable (see below)
            parentToChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

            // Add relation to ParentTable
            gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();

            childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";  // same as SourceListSetEntry.Name for grandChhildTable (see below)
            childToGrandChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            childToGrandChildRelationDescriptor.RelationKeys.Add("childID", "ChildID");

            // Add relation to ChildTable
            parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);

            // Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);

            this.gridGroupingControl1.DataSource = parentTable;

            this.gridGroupingControl1.TableDescriptor.Columns["parentID"].HeaderText = "Parent ID";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["childID"].HeaderText = "Child ID";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Relations[0].ChildTableDescriptor.Columns["GrandChildID"].HeaderText = "Grand Child ID";
        }
示例#4
0
        /// <summary>
        /// Grouping sample Customizations are done here.
        /// </summary>
        private void SampleCustomization()
        {
            //set up the main table
            DataTable dt = GetMainDataTable();
            DataSet   ds = new DataSet("Main");

            ds.Tables.Add(dt);

            this.gridGroupingControl1.DataSource = ds;
            this.gridGroupingControl1.DataMember = dt.TableName;

            //remember the location of lookupcol so it can be swapped out later
            GridTableDescriptor td = this.gridGroupingControl1.TableDescriptor;

            td.VisibleColumns.LoadDefault();
            int lookUpIndex = td.VisibleColumns.IndexOf("Customer");

            //get the lookup table
            DataTable lookUpDataTable = this.GetForeignTable();

            DataSet ds2 = new DataSet("LookUp");

            ds2.Tables.Add(lookUpDataTable);

            //add it to the grouping engine
            this.gridGroupingControl1.Engine.SourceListSet.Add(lookUpDataTable.TableName, lookUpDataTable.DefaultView);

            //set up relation descriptor that defines mapping between main table and foreign table
            GridRelationDescriptor rd = new GridRelationDescriptor();

            rd.Name           = "CustomerColDisplay";             //just some unique name
            rd.RelationKind   = RelationKind.ForeignKeyReference; //foreign key look up
            rd.ChildTableName = lookUpDataTable.TableName;        // SourceListSet name for lookup

            //get foreign key for col "CustomerID" in foreign table
            rd.RelationKeys.Add("Customer", "CustomerID"); //col in main table,  foreign key col

            //Set any optional properties on the relation
            // dropdown only shows CustomerName
            rd.ChildTableDescriptor.VisibleColumns.Add("CustomerName"); //display column
            rd.ChildTableDescriptor.SortedColumns.Add("CustomerName");  //sort it for dropdown display
            rd.ChildTableDescriptor.AllowEdit = false;                  //no editing of foreign table
            rd.ChildTableDescriptor.AllowNew  = false;                  //no new items added to foreign table
            rd.ChildTableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.FromArgb(0xff, 0xbf, 0x34);

            //add relation descriptor to main tabledescriptor
            td.Relations.Add(rd);

            //Add the relation column to main TableDescriptor's Columns collection.
            this.gridGroupingControl1.TableDescriptor.Columns.Add("Customer");

            //Replace maintable.LookUpCol with foreigntable.DisplayCol
            string foreignPrefix = rd.Name + "_";

            //get the hashed name of foreign col
            string foreignDisplayColInMainTable = foreignPrefix + "CustomerName";

            td.VisibleColumns.Insert(lookUpIndex, foreignDisplayColInMainTable);

            //set its headertext to something other than default hashedname
            td.Columns[foreignDisplayColInMainTable].HeaderText = "Customer";
            td.Columns[foreignDisplayColInMainTable].Appearance.AnyCell.BackColor = Color.FromArgb(218, 229, 245);
            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                int index = (new Regex(@"\p{Lu}")).Match(col.MappingName.Substring(1)).Index;
                if (index > -1)
                {
                    col.HeaderText = col.MappingName.Substring(0, index + 1) + " " + col.MappingName.Substring(index + 1);
                }
            }
        }
示例#5
0
        /// <summary>
        /// Group the GridGroingControl by Rating column
        /// </summary>
        void SetupGroupByRatings()
        {
            //
            // In this method we swap the Products and Ratings table. At startup the
            // DataSource is set to the Products table which has a parent child relation
            // with Ratings.
            //
            // In this method we assign the Ratings table as main DataSource and add
            // a ForeignKey relation to the products table. This allows products that
            // have multiple ratings to appear more than once.
            //
            // The foreign key relation from Products to Suppliers will be saved
            // and reapplied in this method.
            //

            GridTableDescriptor mainTd = this.gridGroupingControl1.TableDescriptor;

            this.gridGroupingControl1.Table.CurrentElement = null;

            // Reset all Grouping
            mainTd.GroupedColumns.Clear();
            mainTd.VisibleColumns.Reset();

            // Save the relations we previously defined for Ratings
            copyOfProducsRatings = new GridRelationDescriptor();
            copyOfProducsRatings.InitializeFrom(mainTd.Relations["Ratings"]);

            // Save also Suppliers and RatingDescription so that they can be reapplied.
            GridRelationDescriptor suppliersRd = new GridRelationDescriptor();

            suppliersRd.InitializeFrom(mainTd.Relations["Suppliers"]);

            GridRelationDescriptor ratingsDescriptionRd = new GridRelationDescriptor();

            ratingsDescriptionRd.InitializeFrom(copyOfProducsRatings.ChildTableDescriptor.Relations["RatingDescription"]);

            //
            // Change MappingNames for Columns. The name of the column stays the same.
            //
            foreach (GridColumnDescriptor cd in mainTd.Columns)
            {
                if (cd.MappingName.StartsWith("Ratings_"))
                {
                    cd.MappingName = cd.MappingName.Substring("Ratings_".Length);
                }
                else
                {
                    cd.MappingName = "Products_" + cd.MappingName;
                }
            }

            //
            // Set up foreign key relation from Ratings to Products
            // so that each Product can now appear multiple times, once for each Rating it has.
            //
            GridRelationDescriptor productsRd = new GridRelationDescriptor();

            productsRd.RelationKind   = RelationKind.ForeignKeyReference;
            productsRd.ChildTableName = "Products";
            productsRd.RelationKeys.Add("ProductID", "ProductID");
            productsRd.ChildTableDescriptor.Relations.Clear();

            //
            // Main DataSource is now "Ratings" table. Add foreign key relations to products and
            // restore the Suppliers and RatingDescription relation.
            //
            mainTd.Relations.Clear();
            mainTd.Relations.Add(productsRd);
            mainTd.Relations.Add(ratingsDescriptionRd);
            productsRd.ChildTableDescriptor.Relations.Add(suppliersRd);

            mainTd.Name = "Group by Ratings";

            this.gridGroupingControl1.DataSource = this.productRatingsDataSet2.Ratings;
        }
示例#6
0
        /// <summary>
        /// GridGrouping control getting started customization.
        /// </summary>
        private void GridSettings()
        {
            #region Setting DataSource for GGC

            DataTable parentTable     = GetTable();
            DataTable childTable      = GetChildTable();
            DataTable grandChildTable = GetGrandChildTable();

            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();
            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";
            parentToChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

            gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();
            childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";
            childToGrandChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            childToGrandChildRelationDescriptor.RelationKeys.Add("child ID", "Child ID");

            parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);

            this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);
            this.gridGroupingControl1.DataSource = GetTable();
            this.gridGroupingControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;

            #endregion

            #region Setting GridProperties

            this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordAfterDetails     = false;
            this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails    = false;
            this.gridGroupingControl1.ChildGroupOptions.ShowAddNewRecordAfterDetails        = false;
            this.gridGroupingControl1.ChildGroupOptions.ShowAddNewRecordBeforeDetails       = false;
            this.gridGroupingControl1.NestedTableGroupOptions.ShowAddNewRecordAfterDetails  = false;
            this.gridGroupingControl1.NestedTableGroupOptions.ShowAddNewRecordBeforeDetails = false;
            this.gridGroupingControl1.Table.DefaultCaptionRowHeight      = this.gridGroupingControl1.TableOptions.RecordRowHeight = 25;
            this.gridGroupingControl1.Table.DefaultColumnHeaderRowHeight = this.gridGroupingControl1.TableOptions.ColumnHeaderRowHeight = 25;

            this.SetStyle(ControlStyles.UserPaint, true);
            this.gridGroupingControl1.ThemesEnabled        = true;
            this.gridGroupingControl1.GridVisualStyles     = GridVisualStyles.Metro;
            this.gridGroupingControl1.GridOfficeScrollBars = OfficeScrollBars.Metro;

            // Header Text name cahnge
            this.gridGroupingControl1.TableDescriptor.Columns["parentID"].HeaderText  = "Parent ID";
            this.gridGroupingControl1.TableDescriptor.Columns["ParentRel"].HeaderText = "Parent Relation";
            this.gridGroupingControl1.GetTableDescriptor("MyChildTable").Columns["child ID"].HeaderText = "Child ID";

            //Navigate to other control using tabkey navigation
            this.gridGroupingControl1.WantTabKey = false;

            #region Zooming


            // Initialize the Zooming to GridGroupingControl
            zoom = new ZoomGroupingGrid(this.gridGroupingControl1);
            ZoomGroupingGrid.zoomCell = true;
            //used to set multiextended selection mode in gridgrouping control.
            this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.None;
            //used to set GridCaptionRowHeight.
            zoom.ZoomBorderColor = this.colorPickerButton1.SelectedColor = SystemColors.ActiveBorder;
            zoom.ZoomSize        = new Size(150, 150);
            zoom.ZoomBorderSize  = 15;
            zoom.ZoomFactor      = 1.5f;
            zoom.ZoomImageMode   = ZoomGroupingGrid.ImageMode.Ellipse;
            this.gridGroupingControl1.TableControlQueryAllowSortColumn += new GridQueryAllowSortColumnEventHandler(gridGroupingControl1_TableControlQueryAllowSortColumn);
            #endregion
        }
示例#7
0
        private void CargaGrid()
        {
            DataSet   DSDevuelve = new DataSet();
            DataTable DTMain     = new DataTable();
            DataView  DVMain     = new DataView();
            DataTable DTCargo    = new DataTable();
            DataView  DVCargo    = new DataView();
            DataTable DTEstado   = new DataTable();
            DataView  DVEstado   = new DataView();

            GGCVista.DataSource = null;
            GGCVista.TableDescriptor.Reset();
            GGCVista.TableDescriptor.AllowNew = false;
            GGCVista.Refresh();

            WSComunes.WSComunes WSComun = new WSComunes.WSComunes();
            WSComun.Url = mdlGenerales.DireccionWS + "FazServices/WSComunes.asmx";
            DSDevuelve  = WSComun.DevuelveStore(mdlGenerales.Conexion, "sp_devuelve_personal");
            DTMain      = DSDevuelve.Tables[0];
            DVMain      = DTMain.DefaultView;
            DTCargo     = DSDevuelve.Tables[1];
            DVCargo     = DTCargo.DefaultView;
            DTEstado    = DSDevuelve.Tables[2];
            DVEstado    = DTEstado.DefaultView;

            GGCVista.TopLevelGroupOptions.ShowFilterBar = false;
            GGCVista.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
            GGCVista.TopLevelGroupOptions.ShowAddNewRecordAfterDetails  = false;
            //Limpia Grilla
            GGCVista.DataSource = null;
            GGCVista.DataMember = null;
            GGCVista.ResetTableDescriptor();
            GGCVista.TableDescriptor.Relations.Clear();


            GridTableDescriptor mainTD = GGCVista.TableDescriptor;

            /*Relacion Foreign y llenado de combo ojo*/
            GGCVista.Engine.SourceListSet.Add("CargoRelacion", DTCargo);
            GridRelationDescriptor CargosRd = new GridRelationDescriptor();

            CargosRd.Name           = "Cargo";
            CargosRd.RelationKind   = RelationKind.ForeignKeyReference;
            CargosRd.ChildTableName = "CargoRelacion";  // SourceListSet name for lookup
            CargosRd.RelationKeys.Add("IDCargo", "IDCargo");
            CargosRd.ChildTableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.CadetBlue;
            CargosRd.ChildTableDescriptor.AllowEdit = false;
            CargosRd.ChildTableDescriptor.AllowNew  = false;
            mainTD.Relations.Add(CargosRd);

            /*Relacion Foreign y llenado de combo ojo*/
            GGCVista.Engine.SourceListSet.Add("EstadoRelacion", DTEstado);
            GridRelationDescriptor EstadoRd = new GridRelationDescriptor();

            EstadoRd.Name           = "Estado";
            EstadoRd.RelationKind   = RelationKind.ForeignKeyReference;
            EstadoRd.ChildTableName = "EstadoRelacion";  // SourceListSet name for lookup
            EstadoRd.RelationKeys.Add("IDEstado", "IDEstado");
            EstadoRd.ChildTableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.CadetBlue;
            EstadoRd.ChildTableDescriptor.AllowEdit = false;
            EstadoRd.ChildTableDescriptor.AllowNew  = false;
            mainTD.Relations.Add(EstadoRd);

            GGCVista.DataSource = DTMain;
            FormatColumnas();
            AplicarFilterBar();
        }
示例#8
0
        /// <summary>
        /// GridGrouping control getting started customization.
        /// </summary>
        private void GridSettings()
        {
            #region SetUpGroupingGrid

            DataTable parentTable     = GetParentTable();
            DataTable childTable      = GetChildTable();
            DataTable grandChildTable = GetGrandChildTable();

            //Add Summary row to parent table
            GridSummaryColumnDescriptor gridSummaryColumnDescriptor = new GridSummaryColumnDescriptor();
            gridSummaryColumnDescriptor.DisplayColumn = "GroupID";
            gridSummaryColumnDescriptor.Format        = "  {Count} Records.";
            gridSummaryColumnDescriptor.Name          = "SummaryColumn";
            gridSummaryColumnDescriptor.SummaryType   = Syncfusion.Grouping.SummaryType.Count;
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("SummaryRow", new GridSummaryColumnDescriptor[] {
                gridSummaryColumnDescriptor
            }));


            // Manually specify relations in grouping engine. The DataSet does not need to have any DataRelations.
            // This is the same approach that should be used if you want to set up relation ships
            // between independent IList.
            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();
            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";                // same as SourceListSetEntry.Name for childTable (see below)
            parentToChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

            //Add Summary Row to child table
            gridSummaryColumnDescriptor = new GridSummaryColumnDescriptor();
            gridSummaryColumnDescriptor.DisplayColumn = "ChildGroupID";
            gridSummaryColumnDescriptor.Format        = "  {Count} Records.";
            gridSummaryColumnDescriptor.Name          = "SummaryColumn";
            gridSummaryColumnDescriptor.SummaryType   = Syncfusion.Grouping.SummaryType.Count;
            parentToChildRelationDescriptor.ChildTableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("SummaryRow", new Syncfusion.Windows.Forms.Grid.Grouping.GridSummaryColumnDescriptor[] {
                gridSummaryColumnDescriptor
            }));


            // Add relation to ParentTable
            gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();
            childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";              // same as SourceListSetEntry.Name for grandChhildTable (see below)
            childToGrandChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            childToGrandChildRelationDescriptor.RelationKeys.Add("childID", "ChildID");

            //Add Summary row to GrandChildTable
            gridSummaryColumnDescriptor = new GridSummaryColumnDescriptor();
            gridSummaryColumnDescriptor.DisplayColumn = "GrandChildGroupID";
            gridSummaryColumnDescriptor.Format        = "  {Count} Records.";
            gridSummaryColumnDescriptor.Name          = "SummaryColumn";
            gridSummaryColumnDescriptor.SummaryType   = Syncfusion.Grouping.SummaryType.Count;
            childToGrandChildRelationDescriptor.ChildTableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("SummaryRow", new GridSummaryColumnDescriptor[] {
                gridSummaryColumnDescriptor
            }));


            // Add relation to ChildTable
            parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);

            // Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);

            this.gridGroupingControl1.DataSource        = parentTable;
            this.gridGroupingControl1.ShowGroupDropArea = true;
            this.gridGroupingControl1.AddGroupDropArea("MyChildTable");
            this.gridGroupingControl1.AddGroupDropArea("MyGrandChildTable");


            //Sync the col width with nested table to avoid messing up of RecordPreviewCell

            // The TrackWidthOfParentColumn propetry of a column descriptor ensures that
            // columns are aligned and stay in sync.

            this.gridGroupingControl1.TableDescriptor.Columns[0].Width = 200;
            this.gridGroupingControl1.TableDescriptor.Columns[1].Width = 150;
            this.gridGroupingControl1.TableDescriptor.Columns[2].Width = 150;

            //// synchronize width of columns in child record with width of column in parent record.
            for (int n = 0; n < 3; n++)
            {
                parentToChildRelationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = gridGroupingControl1.TableDescriptor.Columns[n].Name;
            }

            ///same for grandchild table.
            for (int n = 0; n < 3; n++)
            {
                childToGrandChildRelationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = parentToChildRelationDescriptor.ChildTableDescriptor.Columns[n].Name;
            }


            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("GroupID");
            this.gridGroupingControl1.TableOptions.ShowRecordPreviewRow  = true;
            this.gridGroupingControl1.ChildGroupOptions.ShowGroupPreview = true;
            gridGroupingControl1.Appearance.AnyCell.TextColor            = Color.MidnightBlue;
            //this.gridGroupingControl1.TableDescriptor.Columns["GroupID"].Appearance.AnyHeaderCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            //this.gridGroupingControl1.TableDescriptor.Columns["GroupID"].Appearance.AnyHeaderCell.VerticalAlignment = GridVerticalAlignment.Bottom;
            this.gridGroupingControl1.TableDescriptor.Columns["GroupID"].HeaderText    = "Group ID";
            this.gridGroupingControl1.TableDescriptor.Columns["parentID"].HeaderText   = "Parent ID";
            this.gridGroupingControl1.TableDescriptor.Columns["ParentName"].HeaderText = "Parent Name";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["childID"].HeaderText      = "Child ID";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["ChildGroupID"].HeaderText = "Child Group ID";

            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Relations[0].ChildTableDescriptor.Columns["GrandChildID"].HeaderText      = "Grand Child ID";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Relations[0].ChildTableDescriptor.Columns["GrandChildGroupID"].HeaderText = "Grand Child Group ID";
            this.gridGroupingControl1.Table.DefaultColumnHeaderRowHeight = 30;

            #endregion

            this.comboBox1.Items.Add(ConverterOptions.Default);
            this.comboBox1.Items.Add(ConverterOptions.Visible);
            this.comboBox1.SelectedIndex          = 0;
            this.checkBox2.Checked                = true;
            this.checkBox3.Checked                = true;
            this.checkBox5.Checked                = true;
            this.checkBox6.Checked                = true;
            this.colorPickerButton1.SelectedColor = Color.Empty;
            this.colorPickerButton2.SelectedColor = Color.Empty;
            this.comboBox1.SelectedIndexChanged  += new EventHandler(comboBox1_SelectedIndexChanged);

            //Navigate to other control using tabkey navigation
            this.gridGroupingControl1.WantTabKey = false;
        }
示例#9
0
        /// <summary>
        /// Sets the ArrayList datasource to the Grid.
        /// </summary>
        private void SetArrayListData()
        {
            #region Adding data to the ArrayList
            ChildList cl1 = new ChildList();
            cl1.Add(new ArrayListData(1, "Condiments", "Sweets", ""));
            ChildList cl2 = new ChildList();
            cl2.Add(new ArrayListData(2, "Confections", "Deserts", ""));
            cl2.Add(new ArrayListData(2, "Confections", "Candies", ""));
            ChildList cl3 = new ChildList();
            cl3.Add(new ArrayListData(3, "Grains/Cereals", "Breads", ""));
            cl3.Add(new ArrayListData(3, "Grains/Cereals", "Pasta", ""));
            cl3.Add(new ArrayListData(3, "Grains/Cereals", "Cereal", ""));
            ChildList cl4 = new ChildList();
            cl4.Add(new ArrayListData(4, "Meat/Poultry", "Prepared meats", ""));
            ChildList cl5 = new ChildList();
            cl5.Add(new ArrayListData(5, "Produce", "Dried fruit", ""));
            cl5.Add(new ArrayListData(5, "Produce", "Bean curd", ""));
            ChildList cl6 = new ChildList();
            cl6.Add(new ArrayListData(6, "Seafood", "Fish", ""));
            cl6.Add(new ArrayListData(6, "Seafood", "Seeweed", ""));

            ArrayList al = new ArrayList();
            al.Add(new ParentItem("Condiments", "Charlotte Cooper", "Bigfoot Breweries", cl1));
            al.Add(new ParentItem("Confections", "Regina Murphy", "Grandma Kelly's Homestead", cl2));
            al.Add(new ParentItem("Grains/Cereals", "Jean-Guy Lauzon", "Ma Maison", cl3));
            al.Add(new ParentItem("Meat/Poultry", "Shelley Burke", "New Orleans Cajun Delights", cl4));
            al.Add(new ParentItem("Produce", "Mayumi Ohno", "Mayumi's", cl5));
            al.Add(new ParentItem("Seafood", "Robb Merchant", "New England Seafood Cannery", cl6));
            al.Add(new ParentItem("Condiments", "Charlotte Cooper", "Bigfoot Breweries", cl1));
            al.Add(new ParentItem("Confections", "Regina Murphy", "Grandma Kelly's Homestead", cl2));
            al.Add(new ParentItem("Grains/Cereals", "Jean-Guy Lauzon", "Ma Maison", cl3));
            al.Add(new ParentItem("Meat/Poultry", "Shelley Burke", "New Orleans Cajun Delights", cl4));
            al.Add(new ParentItem("Produce", "Mayumi Ohno", "Mayumi's", cl5));
            al.Add(new ParentItem("Seafood", "Robb Merchant", "New England Seafood Cannery", cl6));
            al.Add(new ParentItem("Condiments", "Charlotte Cooper", "Bigfoot Breweries", cl1));
            al.Add(new ParentItem("Confections", "Regina Murphy", "Grandma Kelly's Homestead", cl2));
            al.Add(new ParentItem("Grains/Cereals", "Jean-Guy Lauzon", "Ma Maison", cl3));
            al.Add(new ParentItem("Meat/Poultry", "Shelley Burke", "New Orleans Cajun Delights", cl4));
            al.Add(new ParentItem("Produce", "Mayumi Ohno", "Mayumi's", cl5));
            al.Add(new ParentItem("Seafood", "Robb Merchant", "New England Seafood Cannery", cl6));
            al.Add(new ParentItem("Condiments", "Charlotte Cooper", "Bigfoot Breweries", cl1));
            al.Add(new ParentItem("Confections", "Regina Murphy", "Grandma Kelly's Homestead", cl2));
            al.Add(new ParentItem("Grains/Cereals", "Jean-Guy Lauzon", "Ma Maison", cl3));
            al.Add(new ParentItem("Meat/Poultry", "Shelley Burke", "New Orleans Cajun Delights", cl4));
            al.Add(new ParentItem("Produce", "Mayumi Ohno", "Mayumi's", cl5));
            al.Add(new ParentItem("Seafood", "Robb Merchant", "New England Seafood Cannery", cl6));
            al.Add(new ParentItem("Condiments", "Charlotte Cooper", "Bigfoot Breweries", cl1));
            al.Add(new ParentItem("Confections", "Regina Murphy", "Grandma Kelly's Homestead", cl2));
            al.Add(new ParentItem("Grains/Cereals", "Jean-Guy Lauzon", "Ma Maison", cl3));
            al.Add(new ParentItem("Meat/Poultry", "Shelley Burke", "New Orleans Cajun Delights", cl4));
            al.Add(new ParentItem("Produce", "Mayumi Ohno", "Mayumi's", cl5));
            al.Add(new ParentItem("Seafood", "Robb Merchant", "New England Seafood Cannery", cl6));
            #endregion
            this.gridGroupingControl1.AllowProportionalColumnSizing = true;
            //Assigning DataSource to grid
            this.gridGroupingControl1.DataSource = null;
            this.gridGroupingControl1.DataSource = al;
            this.gridGroupingControl1.Engine.SetSourceList(al);
            //A relationship between tables established by the gridrelation descriptor's UniformChildList.
            GridRelationDescriptor grd = new GridRelationDescriptor();
            grd.RelationKind = RelationKind.UniformChildList;
            grd.MappingName  = "Child";//name of  property with child arraylist

            this.gridGroupingControl1.Engine.SourceListSet.Clear();
            this.gridGroupingControl1.TableDescriptor.Columns.Clear();
            //Adding columns to the Grid table descriptor.
            this.gridGroupingControl1.TableDescriptor.Columns.Add("CategoryName");
            this.gridGroupingControl1.TableDescriptor.Columns.Add("SupplierName");
            this.gridGroupingControl1.TableDescriptor.Columns.Add("CompanyName");
            this.gridGroupingControl1.TableDescriptor.Relations.Add(grd);
            //Setting Column header text.
            this.gridGroupingControl1.TableDescriptor.Columns["CategoryName"].HeaderText = "Category Name";
            this.gridGroupingControl1.TableDescriptor.Columns["SupplierName"].HeaderText = "Supplier Name";
            this.gridGroupingControl1.TableDescriptor.Columns["CompanyName"].HeaderText  = "Company Name";
            //Setting AllowNew and ReadOnly property value.

            foreach (GridTableDescriptor td in this.gridGroupingControl1.Engine.EnumerateTableDescriptor())
            {
                if (td.ParentTableDescriptor != null)
                {
                    td.Columns["CategoryName"].HeaderText = "Category Name";
                    td.Columns["CategoryID"].HeaderText   = "Category ID";
                    td.Columns["OtherInfo"].HeaderText    = "Other Info";
                }
            }

            this.gridGroupingControl1.GetTable("Child").DefaultRecordRowHeight = 22;
        }
示例#10
0
		private void AddGridRelationDescriptor(DashboardView view)
		{
			string[] keys = new string[view.Keys.Count];
			view.Keys.CopyTo(keys);

			//// Add relation to ParentTable 
			GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();
			parentToChildRelationDescriptor.ChildTableName = view.Alias;
			parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;
			foreach (string relation in keys)
				parentToChildRelationDescriptor.RelationKeys.Add(relation, relation);

			gridRelationDescriptors.Add(view.Alias, parentToChildRelationDescriptor);
			gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

			// Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name
			gridGroupingControl1.Engine.SourceListSet.Add(view.Alias, gridRelationDataSets[view.Alias]);
		}
示例#11
0
        /// <summary>
        /// Required Method for sample level customization.
        /// </summary>
        void SampleCustomization()
        {
            DataTable parentTable     = GetParentTable();
            DataTable childTable      = GetChildTable();
            DataTable grandChildTable = GetGrandChildTable();

            // Manually specify relations in grouping engine. The DataSet does not need to have any DataRelations.
            // This is the same approach that should be used if you want to set up relation ships
            // between independent IList.
            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();

            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";    // same as SourceListSetEntry.Name for childTable (see below)
            parentToChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

            // Add relation to ParentTable
            gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();

            childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";  // same as SourceListSetEntry.Name for grandChhildTable (see below)
            childToGrandChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            childToGrandChildRelationDescriptor.RelationKeys.Add("ParentID", "ChildID");

            // Add relation to ChildTable
            parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);

            this.gridGroupingControl1.TableControl.DpiAware = true;
            // Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);

            this.gridGroupingControl1.DataSource = parentTable;

            int freezeCol = 1;  // freeze column 0 and 1.

            //// synchronize width of columns in child record with width of column in parent record.
            for (int n = 0; n <= freezeCol; n++)
            {
                parentToChildRelationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = gridGroupingControl1.TableDescriptor.Columns[n].Name;
            }

            // specify last column to be frozen in child table.
            parentToChildRelationDescriptor.ChildTableDescriptor.FrozenColumn = parentToChildRelationDescriptor.ChildTableDescriptor.Columns[freezeCol].Name;

            // same for grandchild table.
            for (int n = 0; n <= freezeCol; n++)
            {
                childToGrandChildRelationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = parentToChildRelationDescriptor.ChildTableDescriptor.Columns[n].Name;
            }
            childToGrandChildRelationDescriptor.ChildTableDescriptor.FrozenColumn = childToGrandChildRelationDescriptor.ChildTableDescriptor.Columns[freezeCol].Name;

            // specify last column to be frozen.
            gridGroupingControl1.TableDescriptor.FrozenColumn = gridGroupingControl1.TableDescriptor.Columns[freezeCol].Name;

            this.gridGroupingControl1.TableDescriptor.Columns["parentID"].HeaderText   = "Parent ID";
            this.gridGroupingControl1.TableDescriptor.Columns["ParentName"].HeaderText = "Parent Name";
            this.gridGroupingControl1.TableDescriptor.Columns["ParentDec"].HeaderText  = "Parent Description";
            //this.gridGroupingControl1.GetTableDescriptor("parentID").Columns["ChildID"].HeaderText = "Child ID";
        }