문제

I have a WPF GridView, and part of the data needs to be shown in the Totals (both Footer and Group totals), but not in the actual data records.

I thought it would be easy to write a trigger and hide the row based on the row's data, however it turns out that Telerik's GridView uses an unusual panel for virtualization, so although the specified rows get hidden, a blank white space is left where it should go.

Here's my current style. It does hide the row, but it is the equivalent to making the visibility Hidden instead of Collapsed (hides the item, but leaves white space where it is)

<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 have tried setting the ItemTemplate to null, removing the Item from the Telerik's GridViewVirtualizingPanel, and adjusting the Visibility, but none of these options seem to work.

Does anyone know of a way I could accomplish this? I either want to hide (and collapse) the rows based on a trigger, or find a way to get the query of the current Grouped Expression so I can query a 2nd collection and display the results in the Group Total. I have no problem with using Code-Behind or something hackish to accomplish this.

Edit

As an interesting side note, I can set the height to 1, but not 0. Even 1 is too much though, since I can be hiding thousands of records and this leaves a huge white area on the screen.

도움이 되었습니까?

해결책

I posted a question on Telerik's forums as well, and apparently this is not possible. My options are to either filter the result set, or set the Height of the rows to 1.

If I filter the result set, my Aggregates are incorrect. If I set the row height to 1, I still get large areas of whitespace if there are a lot of records hidden (which there are).

My end solution was to set the row height of grouped row to 1, and just show non-grouped items. This means all items show if the data is ungrouped, but when grouped there is a 1px white line which is barely noticeable running through the grid where the hidden items are.

다른 팁

If you can do this in the C#, here's code to auto hide a row in the databind:

 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
 {
   if (e.Item is GridDataItem)
   {
       GridDataItem item = (GridDataItem)e.Item;
       if (item.GetDataKeyValue("EmployeeID").ToString() == "4")  //set your condition for hiding the row
       {
           item.Display = false;  //hide the row
       }
   }
 }

Most Telerik controls respond to a pattern like:

GridEditableItem editedItem = e.Item as GridEditableItem;
editedItem.Display = false;

You can also do Columns:

GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("CustomerID");
if(column != null)
{
column.Visible = !column.Visible;
RadGrid1.Rebind();
}

Here's a similar question/answer: Hide a gridView row in asp.net

Make new boolean property in your binding collection bool: Visible{ge;set;}

Place in gridview and done.

​<telerik:RadGridView.FilterDescriptors>
 <data:CompositeFilterDescriptor LogicalOperator="Or">
 <data:CompositeFilterDescriptor.FilterDescriptors>
 <data:FilterDescriptor Member="Visible" Operator="IsEqualTo" Value="True" />
 </data:CompositeFilterDescriptor.FilterDescriptors>
 </data:CompositeFilterDescriptor>
 </telerik:RadGridView.FilterDescriptors>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top