public Class1() { engine1 = new Engine(); USStatesCollection usStates = USStatesCollection.CreateDefaultCollection(); CountriesCollection countries = CountriesCollection.CreateDefaultCollection(); this.engine1.SourceListSet.Add("Countries", countries); this.engine1.SourceListSet.Add("USStates", usStates); DataTable table = new DataTable(); table.Columns.Add("Id", typeof(string)); table.Columns.Add("Country", typeof(Country)); table.Columns.Add("State", typeof(USState)); // and then add a few rows: for (int i = 0; i < 50; i++) { table.Rows.Add(table.NewRow()); table.Rows[i][0] = i; table.Rows[i][1] = countries[i % 8]; if (i % 8 == 0) { table.Rows[i][2] = usStates[i / 8]; } } TableDescriptor mainTd = this.engine1.TableDescriptor; //mainTd.Fields.ExpandProperties = false; RelationDescriptor usStatesRd = new RelationDescriptor(); usStatesRd.Name = "State"; usStatesRd.MappingName = "State"; // FieldName in table usStatesRd.ChildTableName = "USStates"; // SourceListSet name for lookup usStatesRd.RelationKind = RelationKind.ListItemReference; usStatesRd.ChildTableDescriptor.SortedColumns.Add("Name"); //usStatesRd.ChildTableDescriptor.AllowEdit = false; //usStatesRd.ChildTableDescriptor.AllowNew = false; // users can't modify states. mainTd.Relations.Add(usStatesRd); RelationDescriptor countriesRd = new RelationDescriptor(); countriesRd.Name = "Country"; countriesRd.MappingName = "Country"; // FieldName in table countriesRd.ChildTableName = "Countries"; // SourceListSet name for lookup countriesRd.RelationKind = RelationKind.ListItemReference; countriesRd.ChildTableDescriptor.AllowEdit = true; countriesRd.ChildTableDescriptor.AllowNew = true; // allow user to add countries (these setting will be overriden by CountriesCollection.IsReadOnly / CountriesCollection.IsFixedSize properties if they are true). mainTd.Relations.Add(countriesRd); this.engine1.SetSourceList(table.DefaultView); }
public Class1() { engine1 = new Engine(); USStatesCollection usStates = USStatesCollection.CreateDefaultCollection(); CountriesCollection countries = CountriesCollection.CreateDefaultCollection(); this.engine1.SourceListSet.Add("Countries", countries); this.engine1.SourceListSet.Add("USStates", usStates); DataTable table = new DataTable(); table.Columns.Add("Id", typeof(string)); table.Columns.Add("Country", typeof(string)); table.Columns.Add("State", typeof(string)); // and then add a few rows: for (int i = 0; i < 50; i++) { table.Rows.Add(table.NewRow()); table.Rows[i][0] = i; table.Rows[i][1] = countries[i % 8].CountryCode; table.Rows[i][2] = usStates[i % 8].Key; } TableDescriptor mainTd = this.engine1.TableDescriptor; RelationDescriptor usStatesRd = new RelationDescriptor(); usStatesRd.Name = "State"; usStatesRd.RelationKind = RelationKind.ForeignKeyReference; usStatesRd.ChildTableName = "USStates"; // SourceListSet name for lookup usStatesRd.RelationKeys.Add("State", "Key"); 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); RelationDescriptor countriesRd = new RelationDescriptor(); //countriesRd.Name = "Country"; - default will be ChildTableName = "Countries" countriesRd.RelationKind = RelationKind.ForeignKeyReference; countriesRd.ChildTableName = "Countries"; // SourceListSet name for lookup countriesRd.RelationKeys.Add("Country", "CountryCode"); 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); this.engine1.SetSourceList(table.DefaultView); mainTd.Name = "ForeignKeyReference"; }
public void Load() { //create an integer collection to hold the random numbers intCollection = new IntegerCollection(); //create a new grouping engine and assign it a IList datasource engine = new Engine(); engine.SetSourceList(intCollection); engine.RecordAsDisplayElements = true; //get a reference to the underlying grouping Table theTable = engine.Table; //group by the Value engine.TableDescriptor.GroupedColumns.Add("Value"); //add the Summaries that we want engine.TableDescriptor.Summaries.Add("Int32Agg", "Value", SummaryType.Int32Aggregate); engine.TableDescriptor.Summaries.Add("Vect", "Value", SummaryType.DoubleVector); }
public Class1() { engine1 = new Engine(); CustomerCollection customers = PopulateCustomers.CreateCustomers(); this.engine1.SetSourceList(customers); RelationDescriptorCollection relations = new RelationDescriptorCollection(); // First level RelationDescriptor rd = AddRelation("Level_0", relations); // Subsequent levels for (int level = 1; level < 5; level++) { rd = AddRelation("Level_" + level.ToString(), rd.ChildTableDescriptor.Relations); } this.engine1.TableDescriptor.Relations.InitializeFrom(relations); this.engine1.Table.ExpandAllRecords(); }
public Class1() { engine1 = new Engine(); 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. RelationDescriptor parentToChildRelationDescriptor = new RelationDescriptor(); parentToChildRelationDescriptor.ChildTableName = "MyChildTable"; // same as SourceListSetEntry.Name for childTable (see below) parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails; parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID"); // Add relation to ParentTable engine1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor); RelationDescriptor childToGrandChildRelationDescriptor = new RelationDescriptor(); 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.engine1.SourceListSet.Add("MyParentTable", parentTable); this.engine1.SourceListSet.Add("MyChildTable", childTable); this.engine1.SourceListSet.Add("MyGrandChildTable", grandChildTable); this.engine1.SetSourceList(parentTable.DefaultView); }
public Class1() { InitializeComponent(); bool msdeAvailable = false; if (msdeAvailable) { this.sqlDataAdapter1.Fill(this.dataSet11); //this.dataSet11.WriteXml("CustOrders.xml", XmlWriteMode.WriteSchema); } else { // Read from a xml file instead. ReadXml(this.dataSet11, @"Common\Data\CustOrders.xml"); } this.engine1 = new Engine(); // Setup a integrated summary sd0 = new SummaryDescriptor(); sd0.MappingName = "Quantity"; sd0.SummaryType = SummaryType.DoubleAggregate; this.engine1.TableDescriptor.Summaries.Add(sd0); // Setup custom summaries sd1 = new SummaryDescriptor(); sd1.Name = "QuantityTotal"; sd1.MappingName = "Quantity"; sd1.SummaryType = SummaryType.Custom; sd1.CreateSummaryMethod = new CreateSummaryDelegate(TotalSummary.CreateSummaryMethod); this.engine1.TableDescriptor.Summaries.Add(sd1); sd2 = new SummaryDescriptor(); sd2.Name = "QuantityDistinctCount"; sd2.MappingName = "Quantity"; sd2.SummaryType = SummaryType.Custom; sd2.CreateSummaryMethod = new CreateSummaryDelegate(DistinctInt32CountSummary.CreateSummaryMethod); this.engine1.TableDescriptor.Summaries.Add(sd2); sd3 = new SummaryDescriptor(); sd3.Name = "QuantityMedian"; sd3.MappingName = "Quantity"; sd3.SummaryType = SummaryType.Custom; sd3.CreateSummaryMethod = new CreateSummaryDelegate(StatisticsSummary.CreateSummaryMethod); this.engine1.TableDescriptor.Summaries.Add(sd3); // Setup running totals by displaying the value of a custom counter in an unbound field FieldDescriptor unboundField = new FieldDescriptor("QuantityCount", "", false, ""); unboundField.ReadOnly = false; this.engine1.TableDescriptor.UnboundFields.Add(unboundField); this.engine1.TableDescriptor.QueryValue += new FieldValueEventHandler(unboundField_QueryValue); // Routine that queries for the value this.engine1.TableDescriptor.SaveValue += new FieldValueEventHandler(unboundField_SaveValue); FieldDescriptor unboundField2 = new FieldDescriptor("QuantityCount2", "", false, ""); this.engine1.TableDescriptor.UnboundFields.Add(unboundField2); // Setup custom counter this.engine1.Table.QueryCustomCount += new CustomCountEventHandler(Table_QueryCustomCount); this.engine1.CurrentRecordContextChange += new CurrentRecordContextChangeEventHandler(engine1_CurrentRecordContextChange); this.engine1.Table.QueryVisibleCustomCount += new CustomCountEventHandler(Table_QueryVisibleCustomCount); // Assign data source this.engine1.SetSourceList(this.dataSet11.Order_Details.DefaultView); quantityFieldDescriptor = this.engine1.TableDescriptor.Fields["Quantity"]; // Add a filter so that we can check out difference between VisibleCustomCount (only records that meet criteria are counted) // and CustomCount (all records are counted) this.engine1.TableDescriptor.RecordFilters.Add("[UnitPrice] > 20"); }