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

Inconsistent StyleSelector behavior

13 Answers 138 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert Mills
Top achievements
Rank 1
Robert Mills asked on 08 Apr 2011, 02:31 PM
We are using the GridView from the Q1 2011 build, and we are seeing inconsistent applying of our style selectors.

Once the grid is populated, the items that are visible seem to be fine. When we scroll right, as columns enter visible view, they don't always get the style applied. And, if I scroll back left and then back to the right again, the columns that do or do not get the style applied properly changes, so some that weren't styled now are and vice versa.

I can keep scrolling left and right and see different results each time, this is without reloading any data.

It seems to be worse if I have the deferred scrolling turned on and/or column virtualization turned on, but I still get the behavior with both turned off. I have not tried with row virtualization turned off as the grid won't work with our dataset if we do.

Our data is about 7k rows of about 70 columns wide. We saw this behavior a bit pre Q1 2011, but not nearly as bad, it is every single time now.

Any ideas?

13 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Apr 2011, 02:37 PM
Hi,

 Can you post your StyleSelector implementation?

Regards,
Vlad
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
0
Robert Mills
Top achievements
Rank 1
answered on 08 Apr 2011, 02:48 PM

Sure:

    public class CRSCellStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            Style style = new Style(typeof(GridViewCell));
            Setter visibilitySetter = new Setter(GridViewCell.VisibilityProperty, Visibility.Collapsed);
            Setter readOnlySetter = new Setter(ReadOnlyCell.IsReadOnlyProperty, true);

            CostReportingSystemComposite model = item as CostReportingSystemComposite;
            var cell = container as GridViewCell;

            if (model.IsVendorRow)
            {
                switch (cell.DataColumn.UniqueName)
                {
                    case "CostData.ContractType":
                        style.Setters.Add(readOnlySetter);
                        style.Setters.Add(visibilitySetter);
                        break;
                    case "CostData.FinalMod":
                        style.Setters.Add(visibilitySetter);
                        break;
                    case "DistributionData.OriginalBudgetQuantity":
                        style.Setters.Add(visibilitySetter);
                        break;
                }
                return style;
            }
            return style;
        }
    }

0
Robert Mills
Top achievements
Rank 1
answered on 08 Apr 2011, 04:26 PM
I can replicate this with row styles as well. My style is:

public class QSRowStyleSelector : StyleSelector

 

{

 

 

 

 

    public override Style SelectStyle(object item, DependencyObject container)  

 

 

    {

 

 

 

        QuantitySystemCompositeDecorator model = item as QuantitySystemCompositeDecorator;

 

        if (model.Quantity.IsFloodQuantityCostCode && !model.IsDisplayRowForFloodQuantity)

 

        {

 

 

            Style style = new Style(typeof(GridViewRow));

 

            style.Setters.Add(new Setter(GridViewRow.VisibilityProperty, Visibility.Collapsed));

 

            return style; 
        
}

 

 

 

 

        return base.SelectStyle(item, container);

 

    }

}

 


When the page renders, the 'collapsed' rows are rendered as white space, if I scroll off the screen and back, they are rendered as normal rows, even though they should be hidden.

Thanks,
Bob
0
Accepted
Vanya Pavlova
Telerik team
answered on 08 Apr 2011, 05:43 PM
Hello Robert,

 


This is normal behavior, because you are trying to play with the GridViewRow's Visibility property. This results into blank spaces and other visual issues, because you are directly messing with the visual tree. I strongly recommend you to use the filtering approach in order to display only these items that satisfy your condition.



Best wishes,
Vanya Pavlova
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
0
Robert Mills
Top achievements
Rank 1
answered on 08 Apr 2011, 05:52 PM
While I don't agree with your reasoning, the whole point of "style" selectors is to mess with visual representation, I do agree that filtering would fix the second example.

Unfortunantly the second example was just an easier way to replicate the problem, and filtering doesn't address the first example.
0
Robert Mills
Top achievements
Rank 1
answered on 08 Apr 2011, 08:04 PM
A couple more pieces of information. For the cell level one, the change to using visibility is new, I was originally setting the foreground color to equal the background to suppress the display.

Also, I just redid everything mimicking your ConditionalStyleSelector example and saw the same behavior.

Thanks,
Bob
0
Robert Mills
Top achievements
Rank 1
answered on 11 Apr 2011, 04:16 PM
Good morning,

I wanted to check in and see if this is still considered an open 'ticket' or are we assuming working as intended? Would it be preferable for us to call in? Is there anything else I can provide to help?

Thanks.
0
Vlad
Telerik team
answered on 14 Apr 2011, 07:00 AM
Hello,

 Messing with rows visibility will lead to unpredictable result since the grid virtualization is using this. 

Regards,
Vlad
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
0
Robert Mills
Top achievements
Rank 1
answered on 14 Apr 2011, 03:39 PM
I understand your stance on that. The row example was just an example. The issue I am having is with cell styles, both with setting colors and with hiding, when I scroll horizontally and they go off the screen and then come back on the screen, the style is no longer applied.

Thanks.
0
Vlad
Telerik team
answered on 15 Apr 2011, 07:38 AM
Hi,

 I've attached an example project demonstrating scenario similar to yours with with our Q1 2011 binaries. Everything is working as excepted. 

Let us know if we've missed something. 

Best wishes,
Vlad
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
0
Robert Mills
Top achievements
Rank 1
answered on 15 Apr 2011, 02:07 PM
Thank you, I will look at it this morning and let you know if it solves my issue.
0
Robert Mills
Top achievements
Rank 1
answered on 16 Apr 2011, 12:13 AM
Ok, the styles are working for setting the background and foreground colors the same, I am not sure why I was seeing that before, and your filters suggestion will work for the row scenario, the third item I am seeing is:

Columns in the grid that are hidden through databinding are not collapsing, where they were before. Now I get a big gap of whitespace where the column was.

Before this update, this collapsed the column, is this by design or a bug?
0
Vlad
Telerik team
answered on 18 Apr 2011, 06:13 AM
Hello,

 This issue was fixed shortly our official release. You can get our latest build or wait for the official service pack - this week. 

Greetings,
Vlad
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
Tags
GridView
Asked by
Robert Mills
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Robert Mills
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or