This is a migrated thread and some comments may be shown as answers.

Formatting of rows is lost during scrolling

4 Answers 324 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 17 Jul 2013, 02:54 PM
We have a RadGridView (.NET 3.5 2011 Q2SP1) to display a list of equipment.  If equipment is going to be added, then it is displayed with a white background and black foreground.  If it is equipment that already exists, all fields are marked readonly and the entire line is set to be red with white foreground.

In small unit tests we have not had any noticeable problem with the control.  However we have a setup in Training where there are 25 pieces of equipment and room to add 2 pieces of equipment at the beginning of the list and unlimited amount at the end of the list.

When I populate the grid the formatting goes nuts and is totally lost while scrolling.  Attached are three screenshots of the lost formatting:

First screen is when the list originally loads.  Line 1 and 2 formatted correctly. The 3rd and 5th line are correct.  The 4th line is readonly however it is all gray instead of red!!!

Second screen shot is when I've scrolled down and around line 12 all formatting is completely lost.

Third screen shot is scrolled back to the beginning and again all formatting is lost and the second line is completely unreadable.

I need resolution to this issue.  My users in training will freak out if they see this garbage!

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 18 Jul 2013, 02:02 PM
Hello,

May I ask you to share more detailed information on how have you implemented the formatting? Do you use a CellStyleSelector?

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 18 Jul 2013, 03:07 PM
In our XAML we define the formator:

<tk:RadGridView Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Height="175" Margin="0,5,0,10" Width="960"
                AutoGenerateColumns="False" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserInsertRows="False"
                CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSelect="True" CanUserSortColumns="False"
                HorizontalAlignment="Left" IsFilteringAllowed="False" ItemsSource="{Binding EquipmentToAdd}" MinHeight="150"
                RowIndicatorVisibility="Collapsed" SelectionUnit="Cell" ShowGroupPanel="False" VerticalAlignment="Bottom" ActionOnLostFocus="CommitEdit">
    <i:Interaction.Behaviors>
        <cv:CellValidationBehavior />
        <cf:EquipmentQuickEntryGrid/>
    </i:Interaction.Behaviors>

And our formatter (EquipmentQuickEntryGrid) performs the following:

public class EquipmentQuickEntryGrid : ConditionalFormattingBase
{
    /// <summary>
    /// Initializes the object, clearing the descriptors
    /// </summary>
    /// <param name="sender">The RadGridView we attached to</param>
    /// <param name="e">The RowLoadedEventArgs</param>
    protected override void RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
    {
        if (!(e.Row is GridViewRow))
        {
            return;
        }
 
        var dataSource = (EquipmentToAdd)e.DataElement;
 
        if (!dataSource.IsInUse)
        {
            return;
        }
 
        foreach (var cell in e.Row.Cells)
        {
            cell.Background = GradientRed;
            cell.Foreground = SolidWhite;
        }
    }
}

The boolean that this formatting keys off of is also used in the grid cells themselves which acts as a validator for me that the formatting should have executed.  (the IsReadOnlyBinding boolean controls both the readonly state as well as the color red)

<tk:GridViewDataColumn Width="150" DataMemberBinding="{Binding Path=SerialNumber, Mode=TwoWay}" Header="Serial Number" CellTemplateSelector="{StaticResource isAssetInUseSerialNumberTemplateSelector}" UniqueName="SerialNumber" IsReadOnlyBinding="{Binding IsInUse}" />
<tk:GridViewDataColumn Width="55"  Header="Remove" CellTemplateSelector="{StaticResource isAssetInUseDeleteTemplateSelector}" IsReadOnlyBinding="{Binding IsInUse}" />
0
Accepted
Dimitrina
Telerik team
answered on 18 Jul 2013, 03:16 PM
Hello,

Since the virtualization of RadGridView is turned on by default, it is not recommended to work with the visual elements (i.e. GridViewCell) and their properties. You would better work with the underlined data items. Please refer to our online documentation for a reference. 

In your case I can suggest you to apply a CellStyleSelector and apply the proper Style you need instead of working with the Cells when the RowLoaded event is raised. How does this approach work for you? 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 18 Jul 2013, 08:39 PM
I did as suggested and I'm very happy to say that the formatting is very stable.  

Thanks
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Michael
Top achievements
Rank 1
Share this question
or