Autosize pages containing grids

1 Answer 85 Views
GridView PageView
Jure
Top achievements
Rank 2
Iron
Iron
Iron
Jure asked on 06 Jul 2023, 11:53 AM | edited on 06 Jul 2023, 11:54 AM

Hi,

 

I'm trying to use a PageView as a container for Grids (to eventually function as filters). ViewMode is Explorer bar as I want each page to open individually. I want each page to adjust it's height to the full height of the grid (above the grid I'm planning to include a TextBox for filtering but that's for later). Only the PageView's scrollbar should appear (when needed) not the grid's. I've been combining design settings (ie. Content Size Mode to AutoSizeToBestFit) and code for days and this combination behaves unexpectedly (dare I say it almost randomly). I've attached the source form if someone can help me out.

A few other things (see picture):

- The first time I expand one of the pages it appears gray and empty, without label, bug? (red)

- How do I get rid of the header? (marked yellow)

- Is it possible to include an icon/button aligned to the right of each Filter (to be used for clearing the selection)? (blue dots)

Jure

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 11 Jul 2023, 10:06 AM

Hello Jure,

Thank you for the provided details.

The filter control which you are trying to achieve looks very similar to our RadFilterView control. It has a similar visual presentation (ExplorerBar), no header, and when the filter is applied 3 dots will appear (blue circle in your image) which allows you to clear the applied filter. You can consider using this control instead of modifying the RadPageView.

In this case, you still consider using the RadPageView control. To expand the RadGridView's inside so that only the parent scrollbar is visible, you will need to set the height of the RadGridView so that all rows inside are visible. You can do that in the LoadFilters() method.

 Private Sub LoadFilters()
 . .  .. . . . . .
For Each gridFilter In gridFilters

    gridFilter.Dock = DockStyle.None
    gridFilter.Location = New Point(0, 0)

    ' set the last column to fill the grid
    gridFilter.AllowAutoSizeColumns = True
    gridFilter.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
    gridFilter.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
    gridFilter.Columns(0).BestFit()
    gridFilter.Columns(0).AutoSizeMode = BestFitColumnMode.None

    gridFilter.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top 'Or AnchorStyles.Bottom

    Dim gridCalculatedHeight As Integer = 0
    gridCalculatedHeight = gridFilter.Height
    gridFilter.Height = (gridFilter.Rows.Count * gridFilter.TableElement.RowHeight) + gridFilter.TableElement.RowHeight '(column header row)
. . . . . . .

I will also reference below your other questions.

  • The first time I expand one of the pages it appears gray and empty, without label, bug? (red)

The first time when a page is expanded, it renders the controls inside. While expanding it calculates what size it requires while the RadGridView is rendering which leads to a visual glitch. The next time it is expanded this is not observed as the RadGridView inside is already loaded. 

  • How do I get rid of the header? (marked yellow)

The RadPageViewExplorerBarElement exposes a Header property that represents the RadPageViewLabelElement at the top. To hide it, you can set its Visibility to Collapsed.

Dim explorerBarElement As RadPageViewExplorerBarElement = (TryCast(Me.pageView.ViewElement, RadPageViewExplorerBarElement))
explorerBarElement.Header.Visibility = Telerik.WinControls.ElementVisibility.Collapsed

  • Is it possible to include an icon/button aligned to the right of each Filter (to be used for clearing the selection)? (blue dots)

You can add a custom element to the page Item object. For example:

Dim btn As RadButtonElement = New RadButtonElement("BTN")
With btn
    .AutoSize = False
    .Size = New Size(30, 20)
    .Alignment = ContentAlignment.MiddleRight
End With
Me.pageView.Pages(0).Item.Children(0).Children.Add(btn)

You can also check the attached project. Still, my recommendation will be to check the RadFilterView control which I think will fit in your scenario.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jure
Top achievements
Rank 2
Iron
Iron
Iron
commented on 01 Oct 2023, 10:03 AM

Hi Dinko, thanks for the answer, the notification mail arrived in my spam folder so I didn't see it. Your solution does not work for me and for now I won't be using RadFilterView. Here's a new, simpler question: https://www.telerik.com/forums/calculate-total-grid-height-different-using-different-themes
Dess | Tech Support Engineer, Principal
Telerik team
commented on 04 Oct 2023, 11:57 AM

Hi, Jure, 

Your question has already been answered in the forum thread you have opened on the same topic. Please, see our answer there for more information:

https://www.telerik.com/forums/calculate-total-grid-height-different-using-different-themes#5725440

 
Tags
GridView PageView
Asked by
Jure
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or