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

Bind value to GridViewDataColumn.CellTemplate column

3 Answers 244 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maria
Top achievements
Rank 1
Maria asked on 15 Apr 2011, 04:52 AM
I have the following column in my gridView:

<telerik:GridViewDataColumn Header="Asset">
   <telerik:GridViewDataColumn.CellTemplate>
       <DataTemplate>
           <local:AssetSelector selectedAssetID="{Binding AssetId}"></local:AssetSelector>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

The itemssource for the grid has an ID of the object I want to display in my AssetSelector (it's supposed to work sort of like a comboBox, but a bit more advanced), so what I want to do is to pass the ID value of the current row to my AssetSelector control and it'll display the right data automatically, but I don't seem to get it. 

Also, is there a way to pass a list of objects to my control? (It's just a like an ItemsSource for this control)?

Thanks in advance for your help!

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 15 Apr 2011, 08:48 AM
Hi Maria,

Since I am not quite aware of your custom AssetSelector control, I am sending you a sample project illustrating how you may define a RadComboBox in a CellTemplate. I hope that helps.
 

Greetings,
Maya
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
Maria
Top achievements
Rank 1
answered on 18 Apr 2011, 03:04 AM
Hi Maya,

This example is not really what I'm looking for. What I meant is that my AssetSelector control works like a combobox (in that it offers a user to select a value out of a list of values), so it has a <TextBox> and a <Button>, so when I click this Button, a radWindow pops up and the user can search for the needed value with some fancy filters, so it shouldn't be as simple as a combobox. 
I just can't seem to be able to bind anything to my control. 
And also, when I click this <Button> in my control and radWindow pops up, the grid is not in the editingMode anymore. Are there any workarounds to it?

Thank you!
Maria
0
Zhang
Top achievements
Rank 1
answered on 07 Jun 2011, 02:58 AM
Hi Maria,

I think the Asset column has no DataMemberBinding set, so the RadGridView does not know which value to extract. Add those codes:

<telerik:GridViewDataColumn Header="Asset" DataMemberBinding="{Binding AssetId}">
   <telerik:GridViewDataColumn.CellTemplate>
       <DataTemplate>
           <local:AssetSelector selectedAssetID="{Binding AssetId}"></local:AssetSelector>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

 hope this will help you.

Tags
GridView
Asked by
Maria
Top achievements
Rank 1
Answers by
Maya
Telerik team
Maria
Top achievements
Rank 1
Zhang
Top achievements
Rank 1
Share this question
or