Gantt Control - Cell with Combox Binding
Hi,
is there any way how to binding ViewModel ItemsSource to ComboBox inside Gantt? I have custom column with CellType ComboBox.
I didn't found any similar example. Thanks
Ondrej Rada
I didn't found any similar example. Thanks
Ondrej Rada
SIGN IN To post a reply.
1 Reply
RA
Rachel A
Syncfusion Team
December 16, 2019 09:53 AM UTC
Hi Ondrej,
Greetings from Syncfusion.
We have prepared sample for having combo box column, download the sample from the below link.
Also, find the code example below to implement the same.
[C#]
|
private void Gantt_OnLoaded(object sender, RoutedEventArgs e)
{
ObservableCollection<double> RiskPercent = new ObservableCollection<double>();
RiskPercent.Add(10);
RiskPercent.Add(20);
RiskPercent.Add(30);
RiskPercent.Add(40);
RiskPercent.Add(50);
RiskPercent.Add(60);
RiskPercent.Add(70);
RiskPercent.Add(80);
RiskPercent.Add(90);
// Creating a new custom column with combo box
GridTreeColumn riskColumn = new GridTreeColumn
{
MappingName = "RiskPercentage",
HeaderText = "Risk",
Width = 120,
StyleInfo = new GridStyleInfo
{
CellType = "ComboBox",
ItemsSource = RiskPercent,
HorizontalAlignment =
HorizontalAlignment
.Center,
VerticalAlignment =
VerticalAlignment
.Center
}
};
this.Gantt.GanttGrid.InternalGrid.DropDownSelectionChanged += InternalGrid_DropDownSelectionChanged;
this.Gantt.GanttGrid.Columns.Insert(2, riskColumn);
}
private void InternalGrid_DropDownSelectionChanged(object sender, GridCellComboValueChangedEventArgs args)
{
GridTreeNode node = this.Gantt.GanttGrid.InternalGrid.GetNodeAtRowIndex(args.CellRowColumnIndex.RowIndex);
int risk;
if (node != null && node.Item != null)
{
if (int.TryParse(args.SelectedItem as string, out risk))
{
(node.Item as Task).RiskPercentage = risk;
}
}
} |
Thanks,
Rachel.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
ON Ondrej
- Dec 14, 2019 09:58 PM UTC
- Dec 16, 2019 09:53 AM UTC