This is a migrated thread and some comments may be shown as answers.

Grouping by a GridViewLookupColumn

1 Answer 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 2
Nick asked on 19 Dec 2008, 02:38 AM
Hi,
I've just started working with WinForms so there may just be something I'm missing here - all of my .NET has been Console, Services and ASP.NET until now.   Working in C#.

So I've got a databound grid with a databound lookup column.  Works great, showing the related column.  The problem is when I drag that column up to group by it, I get the value rather than the display value, i.e.  I get the related key value rather than the text displayed in the column, so when grouping by Section column, instead of this

Section: Test
Section: A new section
Section: Test Section

I get:
Section: 1
Section: 2
Section: 3

Where 1, 2,3 are the corresponding keys for Test, A new Section, Test Section.

I would assume I am missing something easy here as this is pretty basic stuff but I can find nothing on the column about what to display when grouping.

Regards,
Nick H

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 20 Dec 2008, 11:56 AM
Hello Nick,

Thank you for contacting us.

Currently, RadGridView does not support showing the DisplayMember instead of the value when grouping by Combo Column. We will add this functionality in a future release.

You could work-around this by using the GroupSumaryEvaluate event to customize the group header row. Please review the code-block below - it shows how to use the event and extract the needed value from combo box column's data source:
 
void radGridView1_GroupSumaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)    
{    
    if (e.Value != null)    
    {    
        BindingSource bs = (this.radGridView1.Columns["TerritoryID"]     
            as GridViewLookUpColumn).DataSource as BindingSource;    
        int index = bs.Find("TerritoryID", e.Value);    
        e.FormatString = e.SummaryItem.FieldName + ": " +     
            ((DataRowView)(bs[index])).Row.ItemArray[1];    
    }    
    else    
    {    
        e.FormatString = e.SummaryItem.FieldName + ": \"emty\"";    
    }    
}   

If you have other questions, do not hesitate to contact me again.

Greetings,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Nick
Top achievements
Rank 2
Answers by
Martin Vasilev
Telerik team
Share this question
or