I'm using the Silverlight 3 radGridView. I'm loading an image that's able to change. I mean, when the user click the image, the row state changes and the image changes too. I do that to offer the possibility of deleting or recovering an item of the grid.
But when I first click the image, the Description field disappears. It exists in the itemsSource but the radGridView doesn't visualize the Description. When a click the image for a second time, the Description field appears again.
In both cases the itemsSource is identical.
Any ideas?
Thanks in advance
3 Answers, 1 is accepted
Please let me see the relevant code . Without having this we can only guess what might be the problem.
Best wishes,
Pavel Pavlov
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Hi Pavel,
I paste you the code:
ASPX:
<telerikGridView:RadGridView x:Name="dgPublicados" ItemsSource="{Binding DatosGrid}"
CanUserFreezeColumns="False" IsReadOnly="True"
AutoGenerateColumns="False" Width="Auto" Grid.Column="0"
AutoExpandGroups="True" ShowGroupPanel="False" IsFilteringAllowed="False"
MaxHeight="300" RowLoaded="dgPublicados_RowLoaded">
<telerikGridView:RadGridView.Columns>
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding RutaEliminar, Mode=TwoWay}" Width="37">
<telerikGridView:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Border Margin="4" CornerRadius="3" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="16" Height="16">
<Image Source="{Binding RutaEliminar}" x:Name="imgEliminar" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Height="16" Width="16" MouseLeftButtonUp="imgEliminar_MouseLeftButtonUp" ToolTipService.ToolTip="Eliminar/Recuperar documento"/>
</Border>
</DataTemplate>
</telerikGridView:GridViewDataColumn.CellTemplate>
</telerikGridView:GridViewDataColumn>
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding RutaDescarga, Mode=TwoWay}" Width="37">
<telerikGridView:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Border Margin="4" CornerRadius="3" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="16" Height="16">
<Image Source="{Binding RutaDescarga}" x:Name="imgDescargar" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Height="16" Width="16" MouseLeftButtonUp="imgDescargar_MouseLeftButtonUp" ToolTipService.ToolTip="Descargar documento"/>
</Border>
</DataTemplate>
</telerikGridView:GridViewDataColumn.CellTemplate>
</telerikGridView:GridViewDataColumn>
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding RutaDescargaPDF, Mode=TwoWay}" Width="37">
<telerikGridView:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Border Margin="4" CornerRadius="3" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="17" Height="17">
<Image Source="{Binding RutaDescargaPDF}" x:Name="imgDescargarPDF" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Top" Height="17" Width="17" MouseLeftButtonUp="imgDescargarPDF_MouseLeftButtonUp" ToolTipService.ToolTip="Descargar documento en PDF"/>
</Border>
</DataTemplate>
</telerikGridView:GridViewDataColumn.CellTemplate>
</telerikGridView:GridViewDataColumn>
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Descripcion}" Header="Nombre del fichero" Width="1*"/>
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Grupo}" IsVisible="False" Width="0"/>
</telerikGridView:RadGridView.Columns>
<telerikGridView:RadGridView.GroupDescriptors>
<data:GroupDescriptor Member="Grupo" SortDirection="Ascending">
<data:GroupDescriptor.AggregateFunctions>
<data:CountFunction Caption="Total:" />
</data:GroupDescriptor.AggregateFunctions>
</data:GroupDescriptor>
</telerikGridView:RadGridView.GroupDescriptors>
</telerikGridView:RadGridView>
<pager:DataPager Grid.Row="1" Source="{Binding ItemsSource, ElementName=dgPublicados}" IsTotalItemCountFixed="True" Margin="0,5,0,5" DisplayMode="FirstLastPreviousNextNumeric" />
ASPX.CS
public
class DatosGrid
{
public long Id { get; set; }
public string RutaEliminar { get; set; }
public string Descripcion { get; set; }
public string RutaDescarga { get; set; }
public string RutaDescargaPDF { get; set; }
public string Grupo { get; set; }
public int Estado { get; set; }
public byte[] Documento { get; set; }
public string TipoMime { get; set; }
}
///
<summary>
/// </summary>
private IEnumerable ItemsSource
{
get
{
var q = from publicado in listaPublicados
select new DatosGrid
{
Id = publicado.Id,
Descripcion = publicado.Descripcion,
RutaEliminar = GetRutaEliminar(publicado.Estado),
RutaDescarga =
"../../Resources/document_attachment.png",
RutaDescargaPDF = GetRutaDescarga(publicado.Mime),
Grupo = publicado.Grupo,
Estado = publicado.Estado,
Documento = publicado.Fichero,
TipoMime = publicado.Mime,
};
return ((IEnumerable)q.ToList());
}
}
/// <summary>
/// </summary>
/// <param name="p_estado"></param>
/// <returns></returns>
private string GetRutaEliminar(int p_estado)
{
string ruta = string.Empty;
switch (p_estado)
{
case 0:
ruta =
"../../Resources/undo.png";
break;
case 1:
ruta =
"../../Resources/delete.png";
break;
case 2:
ruta =
"../../Resources/delete.png";
break;
case 3:
ruta =
"../../Resources/undo.png";
break;
}
return ruta;
}
///
<summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void imgEliminar_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (this.dgPublicados.SelectedItem != null)
{
long idSelected = ((DatosGrid)this.dgPublicados.SelectedItem).Id;
for (int i = 0; i < listaPublicados.Count; i++)
{
if (listaPublicados[i].Id == idSelected)
{
switch (listaPublicados[i].Estado)
{
case 0:
listaPublicados[i].Estado = 2;
break;
case 1:
listaPublicados[i].Estado = 3;
break;
case 2:
listaPublicados[i].Estado = 0;
break;
case 3:
listaPublicados[i].Estado = 1;
break;
}
}
}
PagedCollectionView view = new PagedCollectionView(this.ItemsSource);
view.PageSize = 10;
this.dgPublicados.ItemsSource = view;
this.dgPublicados.UpdateLayout();
}
}
I have tried to reproduce the problem here but with no success. As a side note I would recommend to replace the
this.dgPublicados.UpdateLayout();
with this.dgPublicados.Rebind();If this does not help , please send me the entire project and I will try to debug it .
Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.