BW
Brian Wright
October 22, 2004 04:55 PM UTC
After re-reading my post, I determined that somehow the second item was truncated in my posting.
To be clear, the second items merely states that if I drag a combobox type column to the GridGroupDropArea, I cannot sort the order of the group in the GridGroupDropArea like I can with other groupings that are not from combobox type columns. Instead when I click on the group field name in the GridGroupDropArea it just does nothing rather than reverse the current sort order.
It all works fine with the other columns.
>Hello,
>
>I have some combobox columns in my GridGroupingControl. I want to be able to group by these columns. In addition, I want my group summary rows to display the textual value in the combobox, not the numerical id to which they are bound.
>
>I found a couple of articles describing how to do this, but I have run into a couple of issues with the GridGroupDropArea when used in conjunction with these approaches.
>
>1. If I go the route of using UnboundFields, any UnboundFields that are used for grouping cannot be dragged off of the GridGroupDropArea. To be more clear, if I progamatically specify to use them for Grouping using the GroupedColumns collection, they are stuck with it and the user cannot ungroup by that field (or any unbound field) by dragging it off of the GridGroupDropArea.
>
>2. Then I tried the other route I found in the forums which is to catch the QueryCellStyleInfo event and custom modify any GroupCaptionCell types that come along. This worked fine except that I noticed another issue with the GridGroupDropArea. Apparently I cannot change the sort direction on any grouped columns, where the column is a combobox, by clicking it in the GridGroupDropArea. Columns in my grid that are just textboxes can be sorted just fine. But any columns that are comboboxes in my grid, if I drag them to the GridGroupDropArea, and then click the name in the GridGroupDropArea, it does not do any sorting.
>
>So either route worked fine for me in terms of customizing my Group Summaries to reflect the textual value of the grouped column (not the numerical), but both do not have a fully working GridGroupDropArea.
>
>Any idea on how I could fix either of these problems.
AD
Administrator
Syncfusion Team
October 23, 2004 05:25 AM UTC
Hi Brian,
this is difficult with 2.1.0.9 version. There is some work involved to get that working.
We have added full support for foreign keys in the last few months. The foreign key support lets you specify a RelationKind.ForeignKeyReference support in which you specify the parent and child columns.
You then have the option to display any of the related fields from the foreign table in your parent records and have users select entries from a dropdown. The dropdown table itsself can also be cutomized just like any other TableDescriptor and you can specify which columns to show there, colors etc. Users will also be able to add new entries if you permit this.
Code looks like this:
GridRelationDescriptor countriesRd = new GridRelationDescriptor();
//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.Appearance.AlternateRecordFieldCell.BackColor = Color.Beige;
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);
With such relation setup the country field in the parent table will be replaced with the Countries_Description field with the full name of the country.
When you sort or group by Countries_Description this also works now the way you need it. It will sort by description and also show the description in the group drop area.
Stefan