I have one Grid there i am facing some problems.
My problem are
1. i need to bind combo box in GridRow as per another column value / another selected combo box values. for example, if there are two combo boxes in Grid 1. Feature Name and 2. Discipline then as per selected Feature, Discipline combo box should bind, if i selected "NEF" feature then only "PM" Should bind else CS, AB and CD. I required this functionality while editing a row and adding new row on click to addnewitem button.
2. in Grid i need to show HTML editor on click of a button which is there in Grid Column.
Waiting for your reply.
Thanks
Csingh
10 Answers, 1 is accepted
Considering your first requirement, you may take a look at this blog post that covers the exact same scenario. As for defining a button in a column, you may run through this help article. Once you create the column, you can handle the Click event and execute the desired behavior.
Maya
the Telerik team
Its not working for me because i am using MVVM Design patterns and binding GridComboBox at runtime in ViewModel on grid load events. My Problems are
1. In grid there is 1 column status having 4 values A,B,C and D. on GridRowloading if status is A then in combobox only A and D will bind and if B then B and D, If C then Only C, If D then only D. *** while adding new record using "Click on add new item button" only Status A will be bind.
2. there is two columns feature & Discipline and Two different datasource for Discipline combobox. As per selected feature Discipline will bind with requested datasource.
Please check my code and let me know ASAP, how to make it possible.
in ViewModel :
public
void gridViewTaskPlanning_RowLoaded(object sender, RowLoadedEventArgs e)
{
if (e.Row is GridViewRow && !(e.Row is GridViewNewRow))
{
RadGridView _radGridView = e.GridViewDataControl as RadGridView;
Task _task = e.DataElement as Task;
switch (_task.StatusName)
{
case "A":
e.Row.Background =
new SolidColorBrush(InProgress);
break;
case "B":
e.Row.Background =
new SolidColorBrush(NotStarted);
break;
case "C":
e.Row.Background =
new SolidColorBrush(Postponed);
break;
case "D":
e.Row.Background =
new SolidColorBrush(Completed);
break;
default:
e.Row.Background =
new SolidColorBrush(NotStarted);
break;
}
(_radGridView.Columns[
"Feature Name"] as GridViewComboBoxColumn).ItemsSource = FeatureList;
(_radGridView.Columns[
"Discipline"] as GridViewComboBoxColumn).ItemsSource = DisciplineList;
(_radGridView.Columns[
"Status"] as GridViewComboBoxColumn).ItemsSource = StatusList;
}
}
In XAML :
<
telerik:GridViewComboBoxColumn
UniqueName="Feature Name"
SelectedValueMemberPath="FeatureID"
DisplayMemberPath="FeatureName" IsResizable="False"
DataMemberBinding="{Binding FeatureID,Mode=TwoWay}"
ItemTemplate="{StaticResource FeatureComboBoxCustomTemplate}"
Width="180"
IsReadOnlyBinding="{Binding Path=., Converter={StaticResource GridRowReadOnlyConvertor}}">
<telerik:GridViewComboBoxColumn.Header>
<StackPanel>
<TextBlock Text="Feature Name" VerticalAlignment="Center" TextWrapping="Wrap" />
<TextBlock Text="*" Foreground="Red" />
</StackPanel>
</telerik:GridViewComboBoxColumn.Header>
</telerik:GridViewComboBoxColumn>
<
telerik:GridViewComboBoxColumn
DataMemberBinding="{Binding DisciplineID,Mode=TwoWay}"
SelectedValueMemberPath="DisciplineId"
DisplayMemberPath="DisciplineAlias" IsResizable="False"
ItemTemplate="{StaticResource DisciplineComboBoxCustomTemplate}"
UniqueName="Discipline" Width="90"
IsReadOnlyBinding="{Binding Path=., Converter={StaticResource GridRowReadOnlyConvertor}}">
<telerik:GridViewComboBoxColumn.Header>
<StackPanel>
<TextBlock Text="Discipline" VerticalAlignment="Center" />
<TextBlock Text="*" Foreground="Red" />
</StackPanel>
</telerik:GridViewComboBoxColumn.Header>
</telerik:GridViewComboBoxColumn>
<
telerik:GridViewComboBoxColumn
DataMemberBinding="{Binding StatusID,Mode=TwoWay}"
SelectedValueMemberPath="StatusID"
DisplayMemberPath="StatusName"
UniqueName="Status" Width="80"
ItemTemplate="{StaticResource StatusComboBoxCustomTemplate}"
IsReadOnlyBinding="{Binding Path=., Converter={StaticResource GridStausColumnReadOnlyConvertor}}"
IsResizable="False"
>
<telerik:GridViewComboBoxColumn.Header>
<StackPanel>
<TextBlock Text="Status" VerticalAlignment="Center" TextWrapping="Wrap" />
<TextBlock Text="*" Foreground="Red" />
</StackPanel>
</telerik:GridViewComboBoxColumn.Header>
</telerik:GridViewComboBoxColumn>
in Xaml.cs
gridViewTaskPlanning.RowLoaded +=
new EventHandler<RowLoadedEventArgs>(taskPlanningViewModel.gridViewTaskPlanning_RowLoaded);
Please check Above issues.(very urgent)
waiting for your reply.
Thanks
Csingh
1. You may introduce a property in your Business object holding the available values for a particular item. Once you set them, you need to define the ItemsSourceBinding property of the GridViewComboBoxColumn pointing to it. You may take a look at this forum thread for a reference and sample project on the topic.
2. I believe the blog post stated above answers to your requirements.
Maya
the Telerik team
u r not getting my point. i m not asking how to bind List<string> Types with combo box. i am able to bind GridViewComboBoxColumn with datasource, but my requirement is how to bind same GridViewComboBoxColumn with different itemsource as per rowwise. I mean if grid having 10 rows ,4 columns(one column is GridViewComboBoxColumn ) then for each row as per column1 values GridViewComboBoxColumn should bind with required itemsource.
example
Emp id EmpName Department SubDepartment
1 A Technical Combobox should hasJAVA, C, C++, .NET etc
2. B Account combobox should has SALARY, BANK, TAX etc
3. C HR Combobox should has Tranining, Rcrmt, Apprsl etc
I hope this time its understable for you. If you have any doubt then feel free to revert back.
Thanks
Csingh
Following up the sample project of the mentioned forum thread, you need to extend it just a bit so that it fulfills the goal of having separate source for the ComboBox on the different rows.
I am sending you the sample project with the few improvements made.
Maya
the Telerik team
Can you clarify what is not in MVVM style in the attached project?
Greetings,Vlad
the Telerik team
Still you are not able to understand my requirement. If you check your code then you will find you are not binding your combobox with different itemsource, you are binding combo box with same list and the list having different values.
for your help again i would like to explain my requirement.if you are not able to understand pls revert back.
example
Emp id EmpName Department SubDepartment
1 A Technical Combobox should hasJAVA, C, C++, .NET etcc (Different ItemSource, TechnicalEntityList)
2. B Account combobox should has SALARY, BANK, TAX etc(Different ItemSource, AccountEntityList)
3. C HR Combobox should has Tranining, Rcrmt, Apprsl etc(Different ItemSource, HREntityList)
TechnicalEntityList contain with following fields
1. DepartmentId
2. DepartmentName
Thanks
CSingh
Too bad Telerik never could understand that you wanted to bind two SEPARATE data sources MVVM style (who uses code behind anyways, a coupled nightmare).....to a RadDataGrid.
Would be nice if Telerik's example code in documentation was not for "code behind" and instead focused more on MVVM real world examples.