We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grouping Engine

I''d like to use the grouping engine to return a list of unique items in a table. Can you help... If I have a table with a column X, I want a list of all the unique values of x (equivalent to "Select distinct X from t") Here''s what I''ve figured out: Syncfusion.Grouping.Table theTable; Syncfusion.Grouping.Engine engine = new Syncfusion.Grouping.Engine(); //get all the ArrayList list = new ArrayList(gridData.Rows.Count); foreach (DataRow row in gridData.Rows) { list.Add(AquadorNET.DataExtraction.GetIntFromDBObject(row["X"], -1)); } engine.SetSourceList(list); theTable = engine.Table; I know engine.Table has to have the info I want, I just can''t figure out the namespace. Thanks

3 Replies

AD Administrator Syncfusion Team June 7, 2005 04:52 AM

You could use the grouping engine to do this by adding a SummaryDescriptor of type FilterBarChoicesSummary. This is the way the GridGroupingControl gets its unqiue values for its filtercell dropdowns. The Values property will returns a list of unqiue values. But since you are moving your list into an arraylist anyway, you could just sort teh arraylist and remove the duplicates turning the array list in a list of unique values.
ArrayList list = new ArrayList (gridData.Rows.Count);
foreach (DataRow row in gridData.Rows)
{
     list.Add(AquadorNET.DataExtraction.GetIntFromDBObject(row["X"], -1));
}
list.Sort();
int i = 0;
while (i + 1 < list.Count)
{
    if(list[i] = list[i+1]
    {
        list.RemoveAt(i);
     }
     else
        i += 1;
}
I did not run the above code, so I may have overlooked something, but this is similar to the technique we use the CreateUniqueEntries code in the GridDataBoundGrid FilterBar if you need to see some working code.


ER Eric Robishaw June 7, 2005 08:18 AM

>You could use the grouping engine to do this by adding a SummaryDescriptor of type FilterBarChoicesSummary. Can you provide a quick example... I cannot find FilterBarChoicesSummary in the namespace (using 2.2). Is there a way to use a DataTable as the engine''s Source Data, besides enumerating each row and adding values to an arraylist?


AD Administrator Syncfusion Team June 7, 2005 02:44 PM

FilterBarChoicesSummary is not in 2.2. It is in 3.x. You can make a DataView the datasource, either : engine.SetSourceList(dataTable1.DefaultView); or engine.SetSourceList(new DataView(dataTable1));

Loader.
Live Chat Icon For mobile
Up arrow icon