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

How can I hide a Row in the GridView?

8 Answers 324 Views
GridView
This is a migrated thread and some comments may be shown as answers.
LHR
Top achievements
Rank 1
LHR asked on 09 Nov 2011, 08:58 PM
I would like to hide some rows in a GridView, however setting the Row's visibility to Collapsed still leaves a blank space where the row should be.

The trigger I am using to hide both GridViewGroupRows and GridViewRows looks like this:

<Style TargetType="{x:Type telerik:GridViewGroupRow}">
    <Setter Property="Visibility" Value="Visible" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding Group.Key, RelativeSource={RelativeSource Self}}" Value="SomeValue">
            <Setter Property="Visibility" Value="Collapsed" />
        </DataTrigger>
    </Style.Triggers>
</Style>


I do not want to filter results because I need them for aggregate results in the groups and the footer. So how can I hide specific GridViewRows without filtering the data?

8 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Nov 2011, 08:06 AM
Hi Lhr,

 Setting rows Visibility is not recommended since the rows virtualization will use this property and the result can be unpredictable. 

Greetings,
Vlad
the Telerik team

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

0
LHR
Top achievements
Rank 1
answered on 10 Nov 2011, 01:56 PM
Is there a way to hide or remove the row at all?

I tried using a blank item template, and removing the item from the GridViewVirtualizingPanel, however neither of those appeared to work.

Or as an alternative, can I get the current group query from somewhere so I can query another collection in the AggregateResultsList and add my own data to group summaries?
0
Vlad
Telerik team
answered on 11 Nov 2011, 12:29 PM
Hello,

You can use the grid filtering (or outside of the filtering) to filter rows. As to aggregates you can write complete custom aggregate functions or you can define custom footers. Please check our demos for more info.

Kind regards,
Vlad
the Telerik team

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

0
LHR
Top achievements
Rank 1
answered on 11 Nov 2011, 01:59 PM
Thanks Vlad, would you be able to point me to the demos that do this? I looked through them and didn't see any examples that would let me create a custom aggregate on a Group Row to pull the data from another data source.

I can add regular aggregates, but if I filter the data then the aggregates aren't correct since the data I am trying to aggregate is filteredout. I can also add a custom value to the Group Rows, but I don't know how to get the query that defines what that group contains so I can query the 2nd data source for the correct value.

Its important that I have the aggregate totals in the Group Rows too, not just the Footer
0
Vlad
Telerik team
answered on 14 Nov 2011, 08:39 AM
Hi,

 The custom aggregates demo can be found here:
http://demos.telerik.com/silverlight/#GridView/CustomAggregates

Kind regards,
Vlad
the Telerik team

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

0
LHR
Top achievements
Rank 1
answered on 14 Nov 2011, 02:06 PM
I'm sorry, that does not do what I am looking to do

It creates a custom Aggregate based on currently visible rows. I am looking to create an aggregate based on non-visible rows. Since I cannot hide rows, I am guessing this is not possible with your GridView.
0
Vlad
Telerik team
answered on 14 Nov 2011, 02:08 PM
Hello,

 The example shows how to create custom aggregates. You can modify it to serve your needs. 

Kind regards,
Vlad
the Telerik team

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

0
LHR
Top achievements
Rank 1
answered on 14 Nov 2011, 02:54 PM
The custom aggregate looks like it only aggregates visible grouped data. For this to work, I need it to aggregate non-visible grouped data.

My data rows are either Credits and Debits. I wish to only show the Debits rows, but to provide aggregate totals showing both Credits and Debits. Users can group by any number of fields they want, and they need to be able to see both the total Credits and Debits for that group, however when expanding to view the raw data they only want to see Debit rows.

I thought it would be easy to simply hide the Credit rows based on a trigger, however it turns out hiding a record still leaves a blank space where the record should be. I cannot Filter the data to exclude all Credit rows, because then the Credits would always show up as $0.00 in the aggregate totals.

I do not see how a custom aggregate would help, however just in case I did try copying the code to my project and now I keep getting a run-time error that says:

No generic method 'StdDev' on type 'MyNamespace.Statistics' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.

The only changes I made was to replace double with Decimal.
Tags
GridView
Asked by
LHR
Top achievements
Rank 1
Answers by
Vlad
Telerik team
LHR
Top achievements
Rank 1
Share this question
or