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

Apply Style and Template Selector after Filtering

4 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Charlie
Top achievements
Rank 2
Charlie asked on 22 Sep 2011, 09:04 PM
We are using a GridView that does not auto generate columns.
When the GridViewDataColumns are created, a custom CellTemplateSelector and CellStyleSelector are applied.
These work fine - until a Filter is applied from the Header.
After the Filter is applied, it doesn't appear that our custom Selectors are applied.
Is there a way to force that to happen?  (i.e. force SelectTemplate() and SelectStyle() to be called)

Thank you.

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 23 Sep 2011, 07:10 AM
Hello Charlie,

The two methods SelectStyle() and SelectTemplate() will be invoked on change of the underlying item and its corresponding property. Can you clarify what is the exact scenario that you want to accomplish ? What will be the change after filtering that should cause modification of the applied style and template selectors ?  

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Charlie
Top achievements
Rank 2
answered on 23 Sep 2011, 02:31 PM
Hi Maya,

The styles we apply to cells are related to the contents of the cells around them.
We display data from multiple sql tables in our grid, to do that - we "flatten out" the data.
We have Locations, where Sturctures are Inspected, if there's something wrong with the Structure, Maintenance is done to it.
So, the grid will contain data for a Structure at a Location, multiple Inspections per Structure and possibly multiple Maintenance operations per Inspection.
Example:

Location  Structure  Inspection  Maintenance
  L1             S1             i1              painted
  L1             S1             i1              support added
  L1             S1             i2              painted
  L1             S1             i3              painted
  L1             S1             i3              support fixed

We format cells similar to the above bold and italic formatting above (first Location is bold, subsequent data is italic).
When we Filter the Maintenance column on "support added", there will only be 1 row of data for L1.
Right now, the result will look like this:
  L1             S1             i1              support added

We need it to reapply the Style (and Template) to look like this:
  L1             S1             i1              support added
0
Accepted
Maya
Telerik team
answered on 23 Sep 2011, 02:57 PM
Hi Charlie,

The SelectStyle() method will be called upon change of an underlying property. So, my suggestion would be construct your logic and model so that once filtering is applied and an item change its display order, this property is modified and the SelectStyle() method will be invoked. This depends entirely on your specific settings and the structure of your application.

 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Charlie
Top achievements
Rank 2
answered on 30 Sep 2011, 04:35 PM
Thanks for the reply.
It turned out that SelectTemplate() is being called and the problem was with the code inside that method.
Tags
GridView
Asked by
Charlie
Top achievements
Rank 2
Answers by
Maya
Telerik team
Charlie
Top achievements
Rank 2
Share this question
or