Retrieve filtered data from ALV - filter

Is there an easy way of retrieving the ALV data that is displayed when there are also filters used on that ALV?
The ALV used is an object of CL_GUI_ALV_GRID. When showing it to the user, there is a filter placed on it by default. The user also has a button that processes the data in the ALV. How can I make sure the process only works with the data that is displayed, even if the user places his own filters on the ALV?
e.g: An ALV gets created from an itab that has 10 rows, but because there is also a filter passed on the ALV, only 8 rows are showing. When pressing a button, I only want to work with the 8 rows currently showing to the user.
I have tried finding a function module for this purpose but I can only find a FM which works with the selected rows in an ALV.
EDIT: Further, there is a method called get_filtered_entries, but it only retrieves those entries that are NOT displayed. Using this will be quite time-consuming to make the translation to displayed entries. get_filtered_entries
Thanks in advance.

GET_FILTERED_ENTRIES returns a table of excluded row indices. You just have to skip those in your processing.
" Copy original table
DATA(lit_buffer) = it_out[].
" Get excluded rows
o_grid->get_filtered_entries(
IMPORTING
et_filtered_entries = DATA(lit_index)
).
" Reverse order to keep correct indizes; thnx futu
SORT lit_index DESCENDING.
" Remove excluded rows from buffer
LOOP AT lit_index ASSIGNING FIELD-SYMBOL(<index>).
DELETE lit_buffer INDEX <index>.
ENDLOOP.
EDIT: I debugged cl_gui_alv_grid a little and it doesn't seems like that a filtered version of the original table exists at all. The lines get filtered, sorted, grouped and immediately transferred into a table of cells. Looks like it is nearly impossible to get the displayed rows without a performance drawback.

Related

Insert a new Google Sheets row into Alphabetically Sorted spreadsheet

I am working with two spreadsheets; the first spreadsheet takes a name and then automatically adds it to the next spreadsheet which is sorted alphabetically by name. The problem is, I need a new row to be created, otherwise the data from the row above it gets added along with the name. Here is the query I am using: '=query(Referrals!A2:O, "select * where C is not null order by D")'. I don't think this can be done with a query, so I have been exploring Google App Scripts. I am not sure how to insert into the pre-sorted list, though. Any help is greatly appreciated!
Have you tried offsetting the header so you can run it for the range of the sheet?
=query(Referrals!A:O, "select * where C is not null order by D Offset 1")
That seems to fix some of the issues I've come across.
EDIT:
What about using a filter formula?
=sort(FILTER(offset(Referrals!$A:$O,1,0),offset(Referrals!$C:$C,1,0)<>""),4,true)
If using Apps Script, then you can directly insert a row (via Sheet.insertRows(rowIndex, numRows)) into the sheet at the desired index. But I believe you can achieve what you want by mapping the data in "next spreadsheet" to the names imported via "query" using VLOOKUP. That way when new data is added to "first spreadsheet" it will be sorted accordingly with your formula, but now the data associated will move rows to continue matching their respective row.

Copy and paste ascending cells in data validation

I'm currently setting up a dependent drop down & I've now got it working. The relevant drop-down is in cells L9:L65 with the data for the drop-down being provided in A68:Z68 through to A121:Z121 via the following formula
=ARRAYFORMULA(IFERROR(IF('390'!J9:J65="Livery", TRANSPOSE(FILTER(Operators!$C$2:C, Operators!$C$2:C<>"")), IF('390'!J9:J65="Operator", TRANSPOSE(FILTER(Operators!$B$2:B, Operators!$B$2:B<>"")), ))))
In cell L9 I've set the following data validation as a list from a range
A68:Z68
Which works perfectly. However, when I copy and paste the other cells in the L column all cells relate to A68:Z68 instead of running in ascending order meaning I've just had to manually amend the data validation in L10:L65 to ensure it fetched the correct data and it nearly sent me mad. Considering some of my sheets will incorporate over 200 rows doing this manually is going to prove tedious and time-consuming so I'm hoping someone can show me a way to quickly get each cell corresponding to the correct row without manual intervention?
by standard means (eg. without using a script), this is possible to achieve only manually setting it up row by row (cell by cell) for the whole range.
http://www.chicagocomputerclasses.com/google-sheets-apps-script-dynamic-dependent-dropdown-data-validation-lists/

SSRS Static fields in groups

Good afternoon!
I have created a report with the wizard to create a matrix that is grouped and has drill down rows. I have added filters to the rows and columns and it works great! I then copied that matrix and modified the filters, so I had two matrixes.
But what I really wanted was those two rows in the same matrix, just in different row groups. So I added another group, using the adjacent below option, and then added all the child groupings. However, when I run the report it shows the values for the first row of the drill down data.
When I look at the groupings I can see the one I did manually has a 'Static' field in each row grouping but the ones that the wizard did (with the red ?), they don't have that "extra" row:
What do I need to change or how do I need to add my groups so that I don't get that "static" row and not show the data? I have the visibility set to 'Hidden' and the toggle set up for the prior grouping set data.
Assuming a few things....
the data comes from a single dataset
You are differentiating between Property and Violent crimes by filtering on a column, I'll call it IncidentGroup for the sake of illustration..
I've understood your question ! :)
Get to the point where you had just a single tablix filtered to show 'Property crime'.
Now remove or edit that filter so it shows all the data you need in the report.
Finally, right click on your Matrix1_IncidentCategory row and add a parent group, choose IncidentGroup (or whatever the column is actually called) and check the box to add a group header.
That should be it, there is no need for a second tablix.
Without knowing how you are filtering currently it's hard to give a complete answer but this should get you close, if not all the way there.
If this doesn't work for whatever reason, please post sample data from your dataset output and your current filters.

Laravel - find offset of record in mysql results

I have a MySQL table of records with several fields.
These records are shown and updated live in the browser. They are displayed in an order choosen by the user, with optional filters also choosen by the user.
Sometimes a change is made to one of the records, and it may affect the order for a given user.
In order to position the message correctly in the list, I need to find where its new offset falls after the change to the record. Basically, I need to get the "id" for the record that now comes before it in the MySQL results, so that I can use Javascript on the client side to reposition the record on the screen.
In raw SQL, I'd do something like this:
SET #rank=0;
SELECT rank
FROM
(SELECT #rank:=#rank+1 AS rank,
subQuery.id AS innerQuery,
FROM ...{rest of custom query here}... as subQuery)
AS outerQuery WHERE outerQuery.innerQuery={ID TO FIND};
Then I can just subtract 1 from the resulting rank, and find the ID of the question that comes before the record in question.
Is this kind of query possible with Laravel's query builder? Or is there a better strategy than what I've come up with here to accomplish the same task?
EDIT: There are a lot of records. So if possible I'd like to avoid loading all the records into memory to find the offset of the record. They are originally loaded on the screen in an "infinite scroll" type method, since it would be too much to load all of them at once.

Best practices for adding/editing UI table data while filtering

Does any one know If there are any best-practices for editing/adding data in UI table while its data is filtered?
Example 1:
Suppose we have a table with two options: add new record and edit selected one. Moreover, the table has an option to filter data over column A.
Now, if the table is filtered by filtering column A with value '1' and I want to add a new record with value in column A that matches filter requirements, what should happen:
The table should refresh and display filtered records with selected newly added record.
The table should reset filter and show all records witch new one selected.
The table should do nothing and display filtered records as they were. Newly added record will be displayed when the filter resets.
For me intuitively the best solution is number 1. But then how to solve the problem in example number 2:
Example 2:
If the table is filtered by filtering column A with value '1' and I want to add a new record that in column A has value '2' what should happen:
The table should display filtered records with selected newly added record despite it does not matche the filter.
The table should reset the filter, and all records should be displayed with new one selected.
The table should do nothing and display filtered records as they were.
The same story is when we have filtered records, and in selected record we want to edit value upon which the filtering took place. Does the edited record should than disapear or filtre should be reset?
Or maybe the best way is to disable add/edit operations while filter is on?
I don't know if there is any best practices about it but I have also encountered the problem before. Two different solutions as I came up with:
Edited/Inserted record should not be filtered until the next time a filter is applied or filter is reset. The record should also be shown different (i.e. darker background color, or an icon, or tooltip) than others implying it was edited and is not being filtered.
The record should be left in focus after being edited or inserted. As soon as it loses focus, filter should be applied to it. The ideal solution is if the record is filtered out, it shouldn't immediately go out of vision. For instance it may go invisible with an animation.
I just checked the google docs and libre office, both of them just display the new record regardless of the filter. You need to re-apply the filter to hide them from view (in both cases the column "A" is filtered by "value 1"):

Resources