Angular expandable ui-grid with infinite scroll and dynamic data? - angularjs

I have an expandable ui-grid and need an infinite scroll on the expanded (child) grids. I will only show the first few lines of data, and will rely on the user to scroll to the bottom of the expanded grid to indicate that more data should be read in (there is a potential for a large amount of data).
I understand I can create a function which will be called when more data is needed:
$scope.subGridApi.infiniteScroll.on.needLoadMoreData($scope, $scope.getDataDown);
But when this function ($scope.getDataDown) is called, I don't know which expanded grid needs more data. Is there a way to determine which expanded grid is being scrolled? Once I know that, I can determine the query I need to make to the server to get the next rows of data.

When setting up the infinite scroll of the child grid, you set up the function to be called to get more data:
$scope.subGridApi.infiniteScroll.on.needLoadMoreData($scope, $scope.getDataDown);
The called function (getDataDown) doesn't receive any parameters. But this.grid.api.grid is the current grid, and this.grid.api.grid.parentRow contains the row, which is where I had stored the details of what data I needed to retrieve next.

Related

ag-grid : show the hidden columns (that were dragged out)

I have an ag-grid (free reactjs version) with lots of columns and records to load.
Some columns are not necessary, so the user can drag the columns out of the grid (and hence hide them). This is fine but how can the user show the hidden columns again without refreshing the page?
I don't want to suppress column drag, just a way to undo the hide without refreshing.
Any advice?
Shameless plug: The enterprise version has this feature in two places, Tool Panel and Column Menu.
However, thankfully it is rather easy to implement this feature yourself using a single columnApi call, well... one of these:
resetColumnState()
This will reset the state of the columns to what you initially defined them as. It will basically make everything visible again
setColumnVisible(colKey, visible)
Just pass in the colId of the column (usually what you passed in as 'field'... but it could be different depending on your set up) and a truthy or falsey value and this will show/hide the column
setColumnsVisible(<Array> colKeys, visible)
note the s - other than that it is the same as before, but you provide an array of colKeys that you want to all be hidden or shown. If you wanted to provide an array of all your columns with another array of whether they should be shown or not then use the last option here setColumnState
setColumnState(<Array> columnState)
This is probably overkill for what you are trying to do, but this will allow you to set the state of all the columns, whether they are visible or not, pinned to different sides, fixing the widths, etc.
Basically I can see you doing one of two things:
Create a button that will make all the columns visible and call gridOptions.columnApi.resetColumnState() when it is clicked
-- OR --
Create a list of check boxes that will listen for a change and call one of the other functions. This list could be outside of your grid, or even inside of your grid in a Custom Filter Component (find the athlete column of the first example to see what I mean.)

Angular-ui-grid initialization

I have a search button that triggers Ajax request to fetch data from DB. When the promise is resolved I populate gridoptions.data. The grid is rendered in the screen.
I make some changes in the grid, like hide some columns, enter something into the header filters, change sort order etc.. When I hit the search button again, the data is fetched again and grid is updated with that data but the grid layout remains as is, all the the changes I made earlier in place..
I need to intialize the grid every time I hit search button... I tried redefining gridoptions.columnDefs but that didn't work..
Suggestions please.
Try:
$scope.gridoptions = {} as the first line in the search function, instead of just clearing the columnDefs.

ExtJS5: Infinite Scroll in Tree Grid

Can we have a ExtJs5 Tree Grid Panel which provides below features:
Inifinite Scroll so that rows are rendered with some limit on scroll and not all records at sametime.
On Click of any root node of a particular row (could be 2/3 levels), i can fire a ajax call to populate a grid/form inside the expanded row.
Please provide your expert suggestions in this regard asap.
Thanks !
1. yes you can use infinite scrolling for TreeGrid. Checkout the example
2. If you want expand a row and inside that row you want a form or a grid, then I would say that is nearly impossible. You can only handle this with a custom renderer for the gridpanel and even with this you must create it via Ext.create and render it into the treepanel.
Why dont use something like this: https://fiddle.sencha.com/#fiddle/l26

How to hide grid columns effectively

I have a very large grid with many columns. When the user clicks on the button, it calls a function which analyzes the whole store - cell by cell, if it finds no changes in a particular column, it hides it, othewise the column stays visible. Very often quite a large number of columns get hidden, but as I can see, this operation - column hiding with all this rendering - is very "heavy", so that my browser may alert, that the code runs for too long.
I do hiding like this:
var cols=grid.headerCt.getGridColumns();
Ext.each(cols, function (item, index, all){
if(condition) item.setVisible(false);
});
I tried to use Ext.suspendLayouts() and Ext.resumeLayouts(), but it leads to a bug. Even though operation now runs faster, instead of column hiding only columns' titles get hidden. So, I need a more optimal and working solution.
suspendLayouts() and subsequent resumeLayouts() is one of the ways to go. You only need to call grid.getView().refresh() after you resume the layouts.
Another option would be to call reconfigure, however, this removes the "hidden" columns from the columns menu.

How to dynamically change pagination urls in ExtJS?

I have two data grids. The first auto-loads a list of items (json data store). OnCellClick the first grid fires a dynamically parametrized url and loads data into the second grid. It works fine, but the pagination of the second grid does not focus the new context.
What shall I do to make the pagination work with the new url?
hm your pagination and second grid (which is the one to be dynamical) should share the same store, now on cell click you should only reconfigure the store and start loading it.
if you do like this both grid and pagination will work just fine...
i think currently your paginations uses another sotre (another instance or something) but it MUST use the same store as the second grid...
Not sure what you exactly mean with "does not focus the new context", but are you passing the start and limit parameters to the second grid in the params array of the jsonStore.load call?
If you just want to focus the grid on certain row, you can use focusRow method of GridView.
Perhaps you could post a code example if this did not help?

Resources