jQWidgets Forums

jQuery UI Widgets Forums Grid Access aggregates in hidden grid

This topic contains 10 replies, has 2 voices, and was last updated by  burggraben 10 years, 10 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • Access aggregates in hidden grid #52977

    burggraben
    Participant

    Hi,

    I’ve searched the forums but didn’t find and answer and I’m not sure it’s possible. Here is my problem. I’m using three grid instances on a Bootstrap tab container (class nav-tabs), so the first grid is visible and the other two are in hidden tabs. The first grid needs to access the aggregate for the second grid using secondGrid.jqxGrid(‘getcolumnaggregateddata’, ‘somecolumn’, [‘somevalue’]).somevalue which works fine but only *after* the second tab has been opened once. Before that I get null.
    It’s a little unexpected because the second grid still calls the onReady callback even if the second tab is never visited. I thought that after the ready event the aggregates should be available.
    Is there any way to force the second grid to make the aggregates available in the ready event handler? What piece of code in the grid is run after the ready even when the second tab is clicked / the grid is brought to the foreground?
    Thanks for any info.

    Access aggregates in hidden grid #53037

    Dimitar
    Participant

    Hello burggraben,

    A jqxGrid cannot be intialized from a div with display: none and it does not call its ready callback function until it has been initialized (there is no “onReady” callback in jqxGrid’s API). Thus, there is no way to get the aggregates from a grid that is in an unvisited tab.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Access aggregates in hidden grid #53055

    burggraben
    Participant

    Hi Dimitar,

    Thank you for taking the time to respond. You are absolutely correct. Once the ready function is called the aggregates are available. I guess I am looking for a way to programmatically force a display: none grid to calculate the aggregates. I tried calling render, renderaggregates and refreshaggregates, but they don’t trigger anything.

    Any other ideas how to get aggregates of a hidden grid? If it really is impossible I’d like to put in a feature request for a function that allows to calculate aggregate when when a grid is not displayed. The grid already has all the data, so it should be able to make the calculations.

    Access aggregates in hidden grid #53062

    burggraben
    Participant

    As a workaround I tried to use visibility: hidden instead of display: none. This works fine for letting the hidden grid reach a state where they call ready, but unfortunately there is a visual problem. The three grids use showstatusbar to show a bar at the bottom with the aggregates. Every grids bar is displayed on every other grid, so the longer grids with have the shorter grid status bar displaying somewhere in the middle between two rows.

    Access aggregates in hidden grid #53074

    Dimitar
    Participant

    Hi burggraben,

    To clarify about display: none again: the grid cannot be initialized until it is shown and remains just a div element with no data associated with it. If you wish, you can access the data itself and make the calculations on your own.

    As for the visibility: hidden issue: I thought the grids were hidden inside the unopened tabs. Why would it matter if their status bars overlap? Do you set the visibility to visible once the tabs are opened?

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Access aggregates in hidden grid #53100

    burggraben
    Participant

    Hi Dimitar,

    I guess it’s a feature request. I don’t see a technical reason why the grid cannoy make the aggregate calculations *before* being visible. The only thing I can think of it lazy-loading, eg we don’t want to use up CPU cycles for something we possibly never see. I’d be fine if I had to call a special method to trigger aggregate computation in a display: none grid. I just want a way to access that data before a grid is visible and without duplicating the code inside jqxgrid to calculate it.

    As for the visibility: hidden issue: This happens only because of my current workaround (which works ok, but is very ugly). Basically I overrided Bootstraps tab mechanism to use visibility: hidden instead of display: none. Like this:

             
                .tab-content > .tab-pane,
                .pill-content > .pill-pane {
                    display: block;
                    visibility: hidden;
                    position: absolute;
                    width: 99%;
                }
    
                .tab-content > .active,
                .pill-content > .active {
                    display: block;
                    visibility: visible;
                    position: absolute;
                    width: 99%;
                }
    

    This means that both hiden and visible tabs/grids are display: block; and thus the ready function is called for hidden grids and aggregates are available. Bootstrap now sets visibility to visible when a tab becomes active. Good. One Problem: Status bars never get hidden. So if I have 3 tabs with 3 grids then I will see 1 grid from the open tab (two grids will be hidden via visibility) and I will always see all 3 status bars.
    It appears that jqxgrid uses visibility: visible; internally for the showstatusbar API function. It is set directly as element style so it overrides the visibility: hidden; of the container tab.
    I had to create a second workaround for this which calls the showstatusbar function each time a tab is clicked so that two status bars are hidden and the right one is visible.

    Access aggregates in hidden grid #53104

    Dimitar
    Participant

    Hi burggraben,

    You can use data adapter to calculate the aggregates from the hidden grid’s data directly. Please take a look at the jqxDataAdapter documentation entry (the section about getAggregatedData).

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Access aggregates in hidden grid #53117

    burggraben
    Participant

    Thanks Dimitar. Interesting – I will check this out.

    Access aggregates in hidden grid #53485

    burggraben
    Participant

    Awesome Dimitar. Using getAggregatedData is exactely what I needed. It allow me to get rid of the visibility:hidden tab workaround and revert back to the default display:none for tabs. I am absole to access the aggregates before the grid is displayed and before is called the ready function. Great! One question: Are there any unwanted side effects to calling dataAdapter.dataBind(); before the grid is displayed and then using the same dataAdapter instance for the grid when it is displayed later? Everything appears to work just fine, but I though I’d ask about things to watch out for with this early call to dataBind. Thanks again!

    Access aggregates in hidden grid #53489

    Dimitar
    Participant

    Hi burggraben,

    There are no issues when using an already databound data adapter in jqxGrid.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Access aggregates in hidden grid #53666

    burggraben
    Participant

    Thanks, that is good to hear.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.