How to fetch row selection in Smart Table in List Report SAP Fiori app? - sap-fiori

I am using the List Report template to implement an SAP Fiori app. The type of table is sap.ui.table.Table
I have added an extension for action to add a 'Download' button and I have set it's requiresSelection value to true. But I am not able to fetch the table selection.
I receive error
"Unsupported operation: sap.ui.table.Table#getSelectedIndices must not
be called if a selection plugin is applied."
for the below statement:
var oTable = oEvent.getSource().getParent().getParent().getTable();
//which fetches the table inside Smart Table control
oTable.getSelectedIndices();
Please help.

Try this:
Inorder to get the selected indices for the above error you are getting
var oTable = oEvent.getSource().getParent().getParent().getTable();
oTable.getAggregations("plugins")[0].getSelectedIndices();

Related

Vaadin Grid (Multiselect): restore selection after refresh

A Vaadin grid shows data which is constantly updated by a background process. A user might select one or more rows to carry out various functions. The user might refresh the data from the backend (which updates rows shown in the grid).
The application needs to restore the selected items after a grid refresh.
grid.getSelectedItems() has to return the current instance of the selected items.
Refresh is implemented as follows:
void refresh() {
final var beanSet = grid.getSelectedItems();
dataProvider.refreshAll(); // refresh from backend
grid.asMultiSelect().select(beanSet); // restore previously selected items
}
Updating the grid works fine, but the selection is only partly restored: the "selected" checkbox is checked for the items in beanSet but querying grid.getSelectedItems() still returns the old instances.
Reproducer: https://github.com/skiedrowski/vaadin-grid-restore-selection, package com.example.application.views.idstyle -> check the notification after clicking "Update selected".
What is the correct way to update the selected items?
Context:
Vaadin Flow 23, Grid Pro in multiselect mode
grid items implement equals and hashCode based on an immutable id
grid data provider is a ConfigurableFilterDataProvider fetching paged data from backend
I believe the problem in your sample project is that you're always recycling a set of selected objects which contain the "old" data. You read out a reference to the old items in var beanSet = grid.getSelectedItems(); and store them back into the selection with grid.asMultiSelect().select(beanSet);
A lazy-loading Grid can't know if the programmatically set selection is a collection of objects that are available in the backend - it would need to fetch the entire backing dataset to do that. So when the selection is updated from the server, it could be any objects of the correct type, whether they actually exist in the data set or not.
What could do yourself is pass the selection set to the backend, update the items and then pass them back to the Grid's selection.
An open question that remains is whether Grid should update the selection when a fetch returns items that are equal to items in the selection. I can't immediately tell if that is
a) possible, or
b) a sensible thing to do
This is how we solve this in our application:
A]
fresh items are retrieved lazily
the only time when refreshed selection is needed is when we want to operate with the selected items (such as edit or another action, otherwise obsolete selected items don't matter)
the backend is able to return fresh item by ID
there is no need to update the selection on fetch() (which could introduce inconsistencies if a part of the selection is already updated but the rest haven't been fetched yet)
B]
we have some data providers which just hold wrappers for actual items
so any interaction with the items fetches fresh data under the hood
for the record, this was not done to solve this problem but mitigates it as a sideeffect

How to filter Microsoft Graph API JSON response using Power Query language?

My request is
GET https://graph.microsoft.com/v1.0/applications?$select=appRoles
Because of this I have a problem in PowerApps, I can't show the objects.
Assuming you have...
... a working Custom Connector named myCustConn
... with a GET method called GetRoles
try this:
In the PowerApp, insert a Button control and set its OnSelect property to:
ClearCollect(colAppRoles, myCustConn.GetRoles().value.AppRoles)
Then insert a Gallery control and set its Items property to:
colAppRoles
Then insert a TextBox control into the Gallery template and set its Default property to:
ThisItem.description (or ThisItem.id, etc.)

Filtering Smarttables initial read request

im using a sap Smarttable to display my data from an ABAP Backend server. Additionally im using SmartVariantManagement to apply Variants and make them persistent.
The problem in my Application is the initial Load of the Smarttable. It seems like the table is first loading all the available data without any filters from the inital Variant of my Smartvariantmanagement.
Is there any way to apply the filters of Smartvariantmanagement to the initial Load in the Smarttable?
Or even better: Is it possible to shut down a running odata-read request if i apply a new selection in the smartfilterbar and just run the new one instead?
example 1:
you can avoid the initial request by the smarttable property
enableAutoBinding="false"
you can also set some mandatory fields for filtering, now the user performces an explicit call to the database
example 2:
you can also define a filter in the smarttable function
beforeRebindTable="onBeforeRebindTable"
controller:
onBeforeRebindTable: function (oEvent) {
var oBindingParams = oEvent.getParameter("bindingParams");
oBindingParams.filters.push(new sap.ui.model.Filter("PropertyX", "EQ", "myProperty"));
}
regards

Vaadin Flow Grid. How get the data/rows from grid

i use Grid with DataProvider and lazy loading to load the data into the grid.
How can i get the data from grid after the data was loaded? I mean, i need get a data from grid that already have a data.
i need something like grid.get....
thx.
I would use grid.getDataCommunicator().fetchFromProvider(..) which returns stream of items method for this, see API spec here: https://demo.vaadin.com/javadoc/com.vaadin/vaadin-core/10.0.2/com/vaadin/flow/data/provider/DataCommunicator.html#fetchFromProvider-int-int-
Since Vaadin 17, you can use DataView API to get currently shown item/items in the Grid:
GridDataView<Person> dataView = grid.getGenericDataView();
Person item = dataView.getItem(42);
// or get all shown items
dataView.getItems().forEach(item -> export(item));
Here is an example how to collect the data for export: https://vaadin.com/docs/latest/flow/binding-data/data-provider/#accessing-currently-shown-items

How to get the last inserted row via Odata service

Update:
Using ODATA, How to get the last inserted row in /MySet where MySet.Name = "abc".
I do not want to continuously poll the odata service via model.read(). I know attachChange() or attachDataReceived()methods can be use to get notified automaically. But apart from notification, how to get the 'inserted row'. Also My doubt is how to satisfy the following three conditions here : $top=1, $orderby= Date desc and $filter=NAME eq 'ABC'
The only solution I can think of is to get notified by data inserted via attachDataReceived() and then make a model.read() call with the required filters and additional parameters. Although this would result in these additional 'read' calls.
Original Post Below:
Question: How to pass filters in element binding?
Post: I am using odata service for populating my views.
I want to pass certain filters like $filter=NAME eq 'Scott'
Since I want these parameters to be included only when with odata request for a specific ui-element, I want to include them in bindElement()
specifically something like this
var myFilter = new Array();
myFilter.push(new sap.ui.model.Filter("NAME", sap.ui.model.FilterOperator.EQ, 'Scott'));
var myStandardTile = this.byId("__tile3");
myStandardTile .bindElement("/MySet",{filters:myFilter});
But unfortunately this does not works. When I see the 'network' tab in developer console, Filters are not being added with my request.
You cannot. Neither filter nor sorter nor formatter are supported by element bindings. They are only supported by list and tree bindings.

Resources