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

Custom template in grid

4 Answers 178 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tgaud
Top achievements
Rank 1
Tgaud asked on 08 Sep 2010, 01:11 PM
How can i enable and validate custom cell in a grid ?

If i want my cell to have Both Checkbox AND textbox.. how can i achieve this ?

Thank you

4 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 13 Sep 2010, 02:54 PM
Hi Tgaud,

You can hook for RadGridView.CellValidating event and you can get the actual edit element from e.EditingElement property. At this time you can validate your custom template and set e.IsValid to true or false accordingly.
On the other hand you can validate entered data on a data layer. For more information you can take a look at this blog post.
In order to create custom template for editing you have to use GridViewColumn.CellEditTemplate property. This approach is demonstrated with this online example.

I know that the examples are for Silverlight but they are valid for WPF too.

Greetings,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tgaud
Top achievements
Rank 1
answered on 13 Sep 2010, 04:18 PM
Hello, thanks for answering this.

You demonstrate how to have a template in a cell, but my problem is different.
My problem is :

How can I bind  two different object, in the same cell.

If I want, in the same cell, to Bind Both Checkbox and textbox

Thank you
0
Nedyalko Nikolov
Telerik team
answered on 15 Sep 2010, 07:04 AM
Hello Tgaud,

DataContext of any cell within RadGridView is an instance of your business object. For example if RadGridView is bound to an ObservableCollection<Person>, DataContext of any cell will be an instance of Person class. Now let's assume that Person has two properties FirstName and IsMarried.

<telerik:GridViewDataColumn Header="Complex column">
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <CheckBox IsChecked="{Binding IsMarried, Mode=TwoWay}" />
                                <TextBox Text="{Binding FirstName, Mode=TwoWay}" />
                            </StackPanel>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>

I hope this helps.

All the best,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Tgaud
Top achievements
Rank 1
answered on 15 Sep 2010, 10:01 AM
Yeah but it's two property of the same object... it's not two different object.. 
Tags
GridView
Asked by
Tgaud
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Tgaud
Top achievements
Rank 1
Share this question
or