How can I hide a Row in the GridView?

9 posts, 0 answers
  1. LHR
    LHR avatar
    16 posts
    Member since:
    Apr 2011

    Posted 09 Nov 2011 Link to this post

    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?

  2. Vlad
    Admin
    Vlad avatar
    11043 posts
    Member since:
    Sep 2012

    Posted 10 Nov 2011 Link to this post

    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 >>

  3. Download a free trial of UI for WPF
  4. LHR
    LHR avatar
    16 posts
    Member since:
    Apr 2011

    Posted 10 Nov 2011 Link to this post

    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?

  5. Vlad
    Admin
    Vlad avatar
    11043 posts
    Member since:
    Sep 2012

    Posted 11 Nov 2011 Link to this post

    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 >>

  6. LHR
    LHR avatar
    16 posts
    Member since:
    Apr 2011

    Posted 11 Nov 2011 Link to this post

    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

  7. Vlad
    Admin
    Vlad avatar
    11043 posts
    Member since:
    Sep 2012

    Posted 14 Nov 2011 Link to this post

    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 >>

  8. LHR
    LHR avatar
    16 posts
    Member since:
    Apr 2011

    Posted 14 Nov 2011 Link to this post

    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.

  9. Vlad
    Admin
    Vlad avatar
    11043 posts
    Member since:
    Sep 2012

    Posted 14 Nov 2011 Link to this post

    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 >>

  10. LHR
    LHR avatar
    16 posts
    Member since:
    Apr 2011

    Posted 14 Nov 2011 Link to this post

    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.

Back to Top
Download a free trial of UI for WPF