Hi.
I just start work with telerik components because my boss want by it.
But I have many question....
I have list with some data
class
client
{
public
name {
get
;
set
;}
public
payform {
get
;
set
;}
}
class
payforms
{
public
id {
get
;
set
;}
public
descr {
get
;
set
;}
}
List<client> clientList =
new
List<client>();
I bind this list to my GgridView with 2 columns: client name and client_payform.But client_payform column must be GridViewComboBoxColumn where I can select pay form and after selection update client list. If any client have pyform it must be selected in client_payform column when i open my window.
Please tell me can I do this or not, and if can tell me how. Thanks.
5 Answers, 1 is accepted
Firstly, you may take a look at our online documentation and demos for a reference on the usage of the GridViewComboBoxColumn.
Generally, the idea is as follows:
1. The grid is aware only for the items from its own data source - thus it creates the corresponding columns for each property of the business object.
2. The source of the GridViewComboBoxColumn is quite separate than the one of the grid.
3. What synchronize them is a corresponding property (most commonly of int type) in each of the two sources. The logic inside the column makes the bond between them.
So, in your case, you can expose a new property in the client class - let's say payformID. In the payforms class you may use the id property. Afterwards, when creating the data for the client class, you have to set the payformID property as well. The definition of the column will be as follows:
<
telerik:GridViewComboBoxColumn
DataMemberBinding={Binding payformID}
DisplayMemberPath
=
"Name"
SelectedValueMemberPath
=
"ID"
/>
All the best,
Maya
the Telerik team
Thanks.
But nothing work...
class
client
{
public
string name {
get
;
set
;}
public
int payformid {
get
;
set
;}
}
class
payforms
{
public
int id {
get
;
set
;}
public
string descr {
get
;
set
;}
}
List<client> clientList =
new
List<client>();
List<payforms> payformsList =
new
List<payforms>();
//when app load I fill lists
dataView.ItemSource = clientList;
in XAML I write
<
telerik:GridViewComboBoxColumn
Header
=
"PayForm"
DataMemberBinding
=
"{Binding payformid}"
UniqueName
=
"PayForm"
SelectedValueMemberPath
=
"Id"
DisplayMemberPath
=
"descr"
ItemsSource
=
"{Binding payformsList}"
/>
when page load all lists fill and have data.
RadGridView show column with client name but combobox have no data.
The reason that the GridViewComboBoxColumn is not populated is that it cannot find its corresponding ItemsSource.
You may set it as follows:
(gridView.Columns["PayForm"] as GridViewComboBoxColumn).ItemsSource = payformsList;
All the best,
Maya
the Telerik team
Thanks.
I forgo this line....
I have one question.
How can I know when user change selected item in this combobox?
I want save new vale to database when user change payform.
You may add a handler for the SelectionChanged event of the RadComboBox like follows:
this.AddHandler(RadComboBox.SelectionChangedEvent, new Telerik.Windows.Controls.SelectionChangedEventHandler(comboSelectionChanged));
private void comboSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count != 0)
{
//this ensures a selection from the drop down is performed.
}
}
Maya
the Telerik team