AG Grid Master / Details: How to change setExpanded state from detail grid event? - ag-grid

I have a cell key down event handler, and would like to implement some logic that causes the details grid to collapse when the user presses key up or left when at the edges of the grid.
I access the "master" row via the parent property and then call setExpanded(false) like this:
event.node.parent?.setExpanded(false);
However, there is no effect and the details grid remains open. I'm not aware of another way to gain access to the "api" object for the master grid. Any suggestions?
Thanks!

Related

Aggrid add button Apply and Reset to all Filter toolpanel

As i see when i change any filter value it sends immediate changed filter data.
I need to have two buttons "Apply" & "Reset" at the bottom of filter toolPanel.
On "Apply" it will do backend call with all filters data.
On "Reset" it will reset all filters.
Is it possible or i need to implement own custom ToolPanel ?
AG Grid Allows you the ability to render Apply, Clear, Reset and Cancel Buttons on AG Grid Filters. You can use them like below in filterParams.
filterParams:{
buttons: ['clear', 'apply']
}
try this .
example from AG Grid

ag-grid Master/Detail apply external filter to detail grids

I have several ag grids I'm working with that are setup as Master/Detail. I have an external filter setup on the master and that works fine I can extend it to the detail grid but running into a couple issues:
The filter appears to only apply to expanded nodes. Closing and reopening resets the data, though the filter may still have a value.
I haven't figured out a way for the filter to ignore the master if the filter matches detail but not the master.
How I expand the master where the detail matches. I think I will need to use a a timeout so that the grid isn't expanding and collapsing on each key press, but I don't know how to know which grid has matching data.
The code below is what I have so far for just handling the detail grid but this appears to be very slow (plunker: https://next.plnkr.co/edit/S1PNvugCbjPh55jI).
onFilterTextBoxChanged() {
// this.gridApi.setQuickFilter(document.getElementById('filter-text-box').value);
this.gridApi.forEachNode(function(node) {
console.log('node.detailNode', node)
node.gridApi.forEachDetailGridInfo(function(detailGridApi){
console.log('detailGridApi', detailGridApi);
detailGridApi.api.setQuickFilter(document.getElementById('filter-text-box').value);
})
});
}
Just a suggestion, on each keypress event happening on the filter box ->
1) Before calling quickFilter function, Expand all the detail grid using grid event expandOrCollapse because it somehow does the filtering while its in expanded state.
2) Collapse the grid when search filter box is empty and have cross mark to empty it.
Please ignore if it does not suits ur needs. Thanks!

SAPUI5 VizFrame: How to get the selected data points

I used a VizFrame to display data in my project.
The normal behaviour of the VizFrame when you select data in the graph you see a popover with the data of the selected point. When you select more than one point the content of the popover is something like in the screenshot: popover content.
I tried using attaching myself to the SelectedData Event. The oControlEvent.mParameters contain the data nodes being currently selected for THAT event.
For example: I click node A => the node A is in the oControlEvent.mParameters. => OK
Then I click additionally on node B (so node A and B are selected) => only the node B is contained in the oControlEvent.mParameters. => not OK.
What I need is the set of all nodes that are currently selected in the graph, not just the one that triggered the event.
This information must be contained somewhere, as the Tooltip correctly shows "2 data nodes selected" after the user clicked B.
Thanks for your help.
the oControlEvent.mParameters.data, or oControlEvent.getParameter('data') will (correctly) only contain the elements that actually triggered the event. (may be more than one data point if you select several data points in one go by dragging a rectangular area over the data points)
if you need all currently selected data points, use oControlEvent.getSource().vizSelection() (here, getSource() will return the vizFrame)
Cheers, iPirat

Preserve the scroll position of a Page

I have a page with many elements (forms and tables)
When I want add a row in a table I scroll the page to the table, I press a button to add a row, edit the info in a popup and press OK.
Then I insert the new row in the model and refresh() the model.
At this point the page auto scroll at the top, but I don't want this behavior!
I want that the page stay in the same Y position!
I see that sap.m.page has scrollTo function https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.Page.html#scrollTo
but I don't know how take the position before the refresh()
The Page does unfortunately not have an API to get the current scroll position, but the idea is a good one we consider.
As a workaround you could access some private method of the Page - but only if you accept the risk that it breaks with a future version of UI5:
page.getScrollDelegate().getScrollTop()
To make it safer you should verify both methods exist before calling them and also check the returned value for plausibility. Then you are pretty safe that in the worst case it will again scroll to the top in some future UI5 version.
you have to fill the iTime parameter in scrollTo function - e.g. srollTo(100, 1) - then it works
using 0 for iTime does not work

Check if a record is selected from a dataPointGrid

I have a dataPointGrid and I want to check if a record from it is being selected (mouse clicked on)
Data point grid above. I want to check if a folder (record) is being selected.
Is there a method that does this?
Add ListGrid#addSelectionChangedHandler() on list grid that is called when (row-based) selection changes within this grid. Note this method fires for each record for which selection is modified - so when a user clicks inside a grid this method will typically fire twice (once for the old record being deselected, and once for the new record being selected).
Look at the ListGrid#setSelectionType() as well that defines a listGrid's clickable-selection behavior (MULTIPLE, SINGLE, SIMPLE or NONE)