I have a Master grid, with Row Details, inside the RowDetailsTemplate i have another GridView that are Editable. In this Grid the user can insert new rows and fill the cell with the values. One of the Column have a Combobox inside of it, but when the user click to add a New row, the ComboBox doens't appers in the Cell.
Here some code.
MasterGrid.
<
telerik:RadGridView
x:Name
=
"GridViewNegocios"
Grid.Row
=
"1"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"2"
HorizontalAlignment
=
"Left"
AutoGenerateColumns
=
"False"
CellEditEnded
=
"GridViewNegocios_CellEditEnded"
RowDetailsVisibilityChanged
=
"GridViewNegocios_RowDetailsVisibilityChanged"
RowDetailsTemplate
=
"{StaticResource GridSegmentoDetalhesTemplate }"
LoadingRowDetails
=
"GridViewNegocios_LoadingRowDetails"
RowDetailsVisibilityMode
=
"VisibleWhenSelected"
VerticalAlignment
=
"Top"
IsBusy
=
"{Binding GridNegociosBusy, Mode=TwoWay}"
Margin
=
"5,20,5,20"
telerik:StyleManager.Theme
=
"Office_Silver"
>
Details Grid
<
telerik:RadGridView
x:Name
=
"GridViewSegmentos"
AutoGenerateColumns
=
"False"
Grid.Row
=
"2"
Grid.Column
=
"0"
ShowGroupPanel
=
"False"
CanUserInsertRows
=
"True"
HorizontalAlignment
=
"Left"
Loaded
=
"GridViewSegmentos_Loaded"
ShowInsertRow
=
"True"
Margin
=
"5,10,5,15"
RowEditEnded
=
"GridViewSegmentos_RowEditEnded"
telerik:StyleManager.Theme
=
"Office_Silver"
Grid.ColumnSpan
=
"2"
>
Attached are a image, that shows the problem.
Maybe I'm missing something, can you help me with this?
Thank you!
7 Answers, 1 is accepted
Could you provide a bit more details on your settings ? How do you define your columns ?
It would be great if you could share some relevant code-snippets.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
This is my MasterGrid Declaration:
<
telerik:RadGridView
x:Name
=
"GridViewNegocios"
Grid.Row
=
"1"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"2"
HorizontalAlignment
=
"Left"
AutoGenerateColumns
=
"False"
CellEditEnded
=
"GridViewNegocios_CellEditEnded"
RowDetailsVisibilityChanged
=
"GridViewNegocios_RowDetailsVisibilityChanged"
RowDetailsTemplate
=
"{StaticResource GridSegmentoDetalhesTemplate }"
LoadingRowDetails
=
"GridViewNegocios_LoadingRowDetails"
RowDetailsVisibilityMode
=
"VisibleWhenSelected"
VerticalAlignment
=
"Top"
IsBusy
=
"{Binding GridNegociosBusy, Mode=TwoWay}"
Margin
=
"5,20,5,20"
telerik:StyleManager.Theme
=
"Office_Silver"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewToggleRowDetailsColumn
ExpandMode
=
"Single"
/>
<
telerik:GridViewDataColumn
Header
=
"NegócioID"
DataMemberBinding
=
"{Binding ObjNegocio.NegocioID}"
IsVisible
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"Negócio"
DataMemberBinding
=
"{Binding ObjNegocio.Negocio}"
IsVisible
=
"True"
/>
<
telerik:GridViewDataColumn
Header
=
"PerÃodoID"
DataMemberBinding
=
"{Binding ObjPeriodo.PeriodoID}"
IsVisible
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"PerÃodo"
DataMemberBinding
=
"{Binding ObjPeriodo.Periodo}"
IsVisible
=
"True"
/>
<
telerik:GridViewDataColumn
Header
=
"NegócioAplicacaoID"
DataMemberBinding
=
"{Binding ObjAplicacaoNegocio.AplicacaoNegocioID}"
IsVisible
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"Aplicação"
DataMemberBinding
=
"{Binding ObjAplicacaoNegocio.AplicacaoNegocio}"
/>
<
telerik:GridViewDataColumn
Header
=
"PessoaNegocioPeriodoID"
DataMemberBinding
=
"{Binding PessoaNegocioPeriodoID}"
IsVisible
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"Qtde"
DataMemberBinding
=
"{Binding Quantidade}"
/>
<
telerik:GridViewDataColumn
Header
=
"Custos"
DataMemberBinding
=
"{Binding ValorTotalCusto, StringFormat=\{0:n2\}}"
/>
<
telerik:GridViewDataColumn
Header
=
"Potencial"
Background
=
"Bisque"
DataMemberBinding
=
"{Binding Converter={StaticResource ExpressionCollumnConverter}, Mode=OneWay, StringFormat=\{0:n2\}}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
And this is de Details Grid Declaration:
<
DataTemplate
x:Key
=
"GridSegmentoDetalhesTemplate"
>
<
telerik:RadGridView
x:Name
=
"GridViewSegmentos"
AutoGenerateColumns
=
"False"
Grid.Row
=
"2"
Grid.Column
=
"0"
ShowGroupPanel
=
"False"
CanUserInsertRows
=
"True"
HorizontalAlignment
=
"Left"
Loaded
=
"GridViewSegmentos_Loaded"
ShowInsertRow
=
"True"
Margin
=
"5,10,5,15"
RowEditEnded
=
"GridViewSegmentos_RowEditEnded"
telerik:StyleManager.Theme
=
"Office_Silver"
Grid.ColumnSpan
=
"2"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"PessoaNegocioSegmento"
DataMemberBinding
=
"{Binding PessoaNegocioSegmentoID}"
IsVisible
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"Segmento"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
telerik:RadComboBox
x:Name
=
"cmbSegmentos"
Loaded
=
"cmbSegmentos_Loaded"
SelectedValue
=
"{Binding SegmentoID, Mode=TwoWay}"
Width
=
"100"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
Header
=
"Valor Custo"
DataMemberBinding
=
"{Binding ValorCusto, StringFormat=\{0:n2\}}"
/>
<
telerik:GridViewDataColumn
Header
=
"PessoaNegocioPeriodoID"
DataMemberBinding
=
"{Binding PessoaNegocioPeriodoID}"
IsVisible
=
"False"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
DataTemplate
>
Since the ComboBox is inside a DataTemplate I use it's Loaded Event to assing the ItemSource and the Binding to it. Like this:
private
void
cmbSegmentos_Loaded(
object
sender, RoutedEventArgs e)
{
this
.ComboGridSegmento = sender
as
RadComboBox;
this
.ComboGridSegmento.ItemsSource = ViewModel.obcComboNegocioSegmento;
this
.ComboGridSegmento.DisplayMemberPath =
"Descricao"
;
this
.ComboGridSegmento.SelectedValuePath =
"Codigo"
;
//Setar o Binding
Binding binding =
new
Binding(
"SegmentoID"
);
binding.Mode = BindingMode.TwoWay;
this
.ComboGridSegmento.SetBinding(RadComboBox.SelectedValueProperty, binding);
}
Note, in this way the combo have the items that comes from a List in my ViewModel, it just don't show up when a new row is inserted on RadGridView.
I have tried to reproduce the issue you reported, but unfortunately without any success. Would you take a look at the sample to verify whether I am testing it correctly and whether you can reproduce the same behavior on it ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks for your help, I look into your sample project, and I found something, my ComboBox is in the First column of the GridView, yours is in the Last, When I change the columns and send the combo to the last one, it works!.
Now, my only problem is, when I Call my WCF Service that returns a List of Objects to fill my Details Grid, my combo don't get the old value selected, but in this list i have the ID present in the combo, do you know why it don't be selected automatically?
Note: The ID aren't Int Values, they are GUID, i don't know if this is some kind of problem.
Thank you!
In order to suggest any further, I would need a bit more details. Is the data for the combo box and the details grid available ? Is there an item from the source of the combo corresponding to the GUID property from the business object for the child grid - you need to have equal values so that the corresponding item from the source of the column is displayed ? How do you set the ItemsSource of the column ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Answering your questions:
Yes, the data for combo box and details grid are available.
Yes, there's an item in the combo box source with the corresponding GUID from the details grid source.
Since i need to check for new data everytime that a row details is expanded I attached this on this event of the master grid:
private
void
GridViewNegocios_RowDetailsVisibilityChanged(
object
sender, GridViewRowDetailsEventArgs e)
{
this
.ViewModel.ListaGridSegmentos.Clear();
if
(e.Visibility == Visibility.Visible)
{
PRJ_PessoaNegocioPeriodo row = e.Row.DataContext
as
PRJ_PessoaNegocioPeriodo;
this
.ViewModel.RecuperarSegmentosCombo(row.ObjNegocio.NegocioID);
//And this call other WCF service, and returns a list for my details grid
this
.ViewModel.RecuperarListaPessoaNegocioSegmento(row.PessoaNegocioPeriodoID);
this
.ViewModel.objPessoaNegocioPeriodo = row;
}
}
You see, in the
RowDetailsVisibilityChanged
I call my methods to fill both grid and combo box, because i needto look to different data in any master row when they are "expanded". These methods are async so, maybe this can causing this issue?
There's also other problem, on the combo box collumn if i set the DataMemberBinding like this.
DataMemberBinding="{Binding SegmentoID, Mode=TwoWay}"When I try to change the item of the combo on any row that is already saved, it just don't select, it returns to the index 0. If i remove the DataMemberBinding it works normally.
PS: I'm using this version of controls: 2010.2.812.1040
My first recommendation would be to try with our current official release and test whether you get the same behavior. Furthermore, you definitely need setting DataMemberBinding of GridViewComboBoxColumn (and actually there is no need to set the Mode to "TwoWay'). If the item you select from the combo box is not saved as the selected one, probably the reason is somewhere in the way you define the bindings depending on the underlying business objects. Will it be possible to simulate the same behavior on the project I previously attached ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>