Project Background
Facts About Project
Question
XAML CODE:
<igCombo:XamWebComboEditor Name="IngredientTypeComboEditor" />
<igGrid:XamWebGrid.Columns>
<igGrid:TextColumn Key="Code" HeaderText="Code" Width="Auto" MinimumWidth="20" />
<igGrid:TextColumn Key="TitleAR" HeaderText="Name Arabic" Width="Auto" MinimumWidth="150" />
<igGrid:TextColumn Key="TitleEN" HeaderText="Name English" Width="Auto" MinimumWidth="150" />
<igGrid:TemplateColumn.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=???, Source={???}}" /> </DataTemplate>
</igGrid:TemplateColumn.ItemTemplate>
<igGrid:TemplateColumn.EditorTemplate>
<ComboBox Name="ComboIngredientType" ItemsSource="{Binding ???}" />
</DataTemplate>
</igGrid:TemplateColumn.EditorTemplate>
</igGrid:TemplateColumn>
</igGrid:XamWebGrid>
VB CODE:
Dim SRV As New DomainService1
Private Sub LoadData()
Me.grdList.ItemsSource = SRV.Ingredients
Me.IngredientTypeComboEditor.ItemsSource = SRV.D_IngredientTypes
Me.IngredientTypeComboEditor.DisplayMemberPath = "TitleEN"
SRV.Load(SRV.GetD_IngredientTypeQuery)
End Sub
Hi
But this event DataGrid1_CellEnteredEditMode does not work for adding new row.
When XAMwebGrid is used for adding a new row , what is the process suggested by Infragistic ?
Shahzad
Hi,
The DataContext of the DataTemplate properties of a TemplateColumn are the data for the row, in which a cell represents. So, in the ItemTemplate, if you have a property that represents an IngredientType on your Ingredient object, then you would just set that has the Path. And there would be no need to set the Source, as the DataContext would be your source.
As for your ComboBox's ItemSource, you should make a static resource and set that as the ItemsSource for your Combobox, as that would be the simplest approach. If that isn't possible, you can use the CellEnteredEditMode event and and check that your in your TemplateColumn, grab the editor ,cast it as a ComboBox and set the Itemssource.
void DataGrid1_CellEnteredEditMode(object sender, EditingCellEventArgs e)
{
if(e.Cell.Column.Key == "myTempCol")
((ComboBox)e.Editor).ItemsSource = myItemsSource;
}
-SteveZ