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

How to use different style for different grouprow?

4 Answers 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 Aug 2008, 06:41 PM
I have three-levels grouping in GridView.

I would like to specify the different style for different level for GroupRow. Is it possible to do that?

For example
-AAA (GroupRow)
-----BBB (GroupRow)
----------CCCC(Normal Row)

I want to set as below.

- Set blue color to AAA GroupRow.
- Set Yellow Color to BBB and put Textbox called TextboxLevel2 in style
- Set Pink color to CCC and put Checkbox in normal rows.

Is it possible to do that with Telerik Datagrid? Can get the value of TextboxLevel2 at runtime?


4 Answers, 1 is accepted

Sort by
0
Chris
Telerik team
answered on 12 Aug 2008, 04:07 PM
Hello Michael,
Currently the GridViewGroupRow ItemsControl has a Record property which returns an object of type GroupRecord. The GroupRecord class has a Level property which you could use to check the level of grouping and apply the respective style for GridViewGroupRow.
Should you have any problems implementing this scenario, don't hesitate to contact us and we'll try to send you a sample project.

Regards,
Nedyalko Nikolov,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 12 Aug 2008, 06:00 PM
Thanks. Yes. It would be great if you can send me the sample project. Thanks.

Actually, I'm not so sure how to set the style to a particular row of child grid or etc..

Updated:

How can I specify the column manually without using AutoGenerateColumns?

Let's say there are 10 fields in my entity object. I want to group-by two fields and want to show only field.. How can I do that?

I tried as below but not working..

<telerik:RadGridView Margin="8,6,32,0" Name="radGridView1"                         
                         ItemsSource="{Binding Source={StaticResource viewModel}, Path=GetData}" ShowGroupPanel="False"
                         AutoGenerateColumns="False"
                        >
            <telerik:RadGridView.GroupDescriptions>
                <telerik:RadGroupDescription PropertyName="Field1" SortDirection="Ascending" />                                   
                <telerik:RadGroupDescription PropertyName="Field2" SortDirection="Ascending" />               
            </telerik:RadGridView.GroupDescriptions>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataType="{x:Null}" IsReadOnly="True" HeaderText="Field 3" UniqueName="Field3" />
                <telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="" UniqueName="{x:Null}">
                    <telerik:GridViewDataColumn.CellStyle>
                        <Style TargetType="{x:Type telerik:GridViewCell}">
                            <Setter Property="Template" Value="{StaticResource DataBoundCommandColumnTemplate}"/>
                        </Style>
                    </telerik:GridViewDataColumn.CellStyle>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

Any idea?
0
Nedyalko Nikolov
Telerik team
answered on 13 Aug 2008, 12:40 PM
Hello Michael,

I have attached a sample project, which demonstrates styling of different group levels and hidden columns, by which the grid can be grouped.

You can style GridViewGroupRows using DataTriggers as shown in the example. The example shows setting the foreground property. However, for some properties (for example, the background) you'll have to redesign the template of GridViewGroupRow to be able to use your background by defining Background="{TemplateBinding Background}" in your custom template (this is due to some small issues in our themes).

When the grid is grouped by hidden columns, users cannot group using the UI. However, grouping can still be performed programmatically by manually adding (or removing) group description, as shown in the example.
There are two minor problems you should be aware of. First, in XAML, the group descriptions must be defined below the column definitions. And second, when group descriptions are added, there should be a check if a group description with the same property name has already been defined. We are working towards fixing these issues.

Hope this helps.

Regards,
Nedyalko Nikolov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 13 Aug 2008, 03:10 PM
Hi Michael,

After we'd sent you the sample project we noticed a little problem with the group descriptions in the GridView group panel. I'm attaching an updated project which references the latest build of RadGridView. In this build we've already fixed the problem with the ListCollectionView you've reported earlier.

Sincerely yours,
Nedyalko Nikolov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Chris
Telerik team
Michael
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or