Saving pagination in Oracle Apex Interactive Report - javascript

Recently I've come across the problem in Oracle Apex 4.2.0003 with saving pagination in Interactive Report. I have a page, in which there are two reports: the first one is Classic, and the second one is Interactive, at that they are working as "master-detail".
Besides, Interactive report has both data from a view and HTML-elements like icons with links to modal or pop-up windows. All in the page works fine except one thing: refreshing of it leads to resetting the pagination of "detail" Interactive report in spite of full refresh or partial (without resetting the Classic, "master" one).
I've tried to solve the problem with javascript: I've written some code, which got current pagination from page and saved it just before updating, and the updating itself went by means of function gReport.navigate.paginate. I could use this way, but it didn't take into account the cases when there were less rows than the count of them chosen in the Interactive Report panel (where also there are search bar etc.).
Another way of solving my problem I'm considering now is getting information about current row count per page from the view APEX_APPLICATION_PAGE_IR_RPT, but I don't know how to get not information from the column interactive_report_id, but from the one named report_id.
Of course, I have the way which leads through getting information by having session ID and the kind of view (which can be customized in Interactive Report panel), but I can't say I like it.
So I have the following question: how to make Interactive Report NOT to reset pagination in my case? Is it possible to make it easier than to get the information from APEX views?

This is a question which pops up from time to time and this is still an issue in apex 5, being that there is no supported way to do this, even though all it requires is opening up the api a bit so we wouldn't need to hack it.
You can use gReport.navigate.paginate for sure, and I'd recommend to go with that. Mind though: it's unsupported by Oracle (as in: undocumented) and it does not work in apex 5 (the JS for IRs has been redone). However, even in apex 5 the methodology remains similar: just "hack" it.
I would NOT query views. You still need IDs from the report and communicate with the backend, and you'll create many more problems than you actually need.
Just figure out in javascript when there is pagination or not.
HTML in the IR when there are more rows than the allowed rows per page:
<td colspan="18" class="pagination" align="left">
<span class="fielddata"> 1 - 15 of 1878
<a href="javascript:gReport.navigate.paginate('pgR_min_row=16max_rows=15rows_fetched=15')">
<img src="/i/jtfunexe.gif" title="Next" alt="Next" align="absmiddle">
</a>
</span>
</td>
HTML when there are less or equal rows than amount allowed:
<td colspan="18" class="pagination" align="left"><span class="fielddata"> 1 - 1 of 1 </span></td>
So: you can check if there is an anchortag in there or not.
If yes: perform your 'paginate' function.
If not: do a refresh.

Related

Material-UI Grid updates with latest data only if I click on it

A working model that replicates the problem, described in the title, is here:
https://codesandbox.io/s/workingreactgrid-zvz12
In the program, the first thing to do is to enter any arbitrary date in the Date of Sale datepicker (under 'Exit Price' on the left). This creates a table that will appear below the inputs. Now the problem I am running into is that when I enter any number for "Rents - Monthly" or for any of the other expenses, e.g. Repairs & Maintenance, Insurance, etc., the numbers will only appear in the table after I manually click on the table.
My research suggests that I am probably doing something wrong with my useEffect in the App component. My hypothesis is that the table is simply 're-rendering' when I click on it, thereby updating it to the latest state. I could be wrong, but I think that's probably somewhere on the right track. But after a week of trying to explore different approaches and failing to get the table to automatically show the latest input data, I'm ready to ask for help.
In the Sandbox link above, nearly all the relevant code is contained in the App and Inputs component. I cleaned it up heavily so that it's easier to troubleshoot, so hopefully it helps.

Programmatically setting the number of displayed rows in a Bootgrid table

Hi I'm writing a web app using rails and as part of it I am displaying data to the user using jQuery Bootgrid. As part of this the user is able to set the number of rows per page of the table. I'd like to be able to have this setting persist between page loads.
When a user chooses an option for the number of rows to display I am able to capture that and store in a model. However Bootgrid doesn't seem to have a simple way of programmatically setting the number of rows. This seems like a common thing to want to do so if anyone has come across this before and can give some help it would be greatly appropriated.
you can find a "setRowCount" implemented in
https://github.com/rstaib/jquery-bootgrid/issues/215 - jquery.bootgrid.modified.txt
Unfortunately the user didn't see fit to properly fork the repo.
Not my best code but it is working:
With jquery fire click event of number of rows that you want...
$("#grid-basic1-header .dropdown:visible [data-action='-1']").click();

asp.net MVC 2 view with slow UI responsiveness

My web application MVC View displays a grid of records, some of which the user can select and post their data back to the server. As long as the record count is in the order of multiples of dozens, the page is responsive. Problems occur when the records are in the order of a thousand and a half.
I've experienced two kinds of problems, one in chrome, one in IE 11. First of all the query to retrieve the records from the DB is kind of slow, but acceptable, let's say that after 5=10 seconds the controller will call a "return view()" passing a model which is a collection of about 1500 records.
Then this happens in Chrome: the browser renders the page quick enough considered the number of record, but after that the page becomes unresponsive in all its elements: as an example, consider the to activate a checkbox, it takes about 10 seconds before you see the check mark after you clicked.
In IE11 this happens instead: the page hangs for about three minutes between the jquery method "document.ready" and its anonymous handler function. After that the page renders all its elements and its responsiveness is acceptable.
My Application is developed in MVC2, and besides jquery, it uses datatables to display the grid, together with bootstrap for styling. Every record has about 20 fields so the page will have 20 form controls (input type=hidden) to post back for each selected record.
Considering that nothing of the above happens when I'm retrieving a few records, can you help me understand what's going on and how I can give performance to my web page?
Thanks in advance......

Html.AntiForgeryToken() breaking pagination behavior

Context
Our web application has a feature for example "Create Employee". It shows three pages (1 of n) to allow user to enter relevant information on each page. On page 3, Save button allow user to save the employee. If user enter a incorrect value in a field on page 1 (something server can only verify) and server reports an error, the default behavior is to display page 1 with error message on top and the relevant field is mark as red.
Problem Statement
Above was all working until recent few build shows a breaking behavior. In above mentioned scenario, on error, the page 2 is displayed instead of page 1. Everything else is working fine like error message is correct, field on page 1 is marked red.
Analysis
I tried looking into pagination logic in java script, reverted back to version changes which was working. I also tried solution proposed here, here. I also cleared browser cache and reopen it.
Nothing worked.
Then I discovered major changes in UI code base was introduction of AntiForgeryToken(). I removed it from page and controller and everything worked again. I checked AntiForgeryToken() is not throwing exception.
Question
I am not sure how AntiForgeryToken() is affecting pagination code in java script?
What can I try to know more about the root cause?
Any proposed solution, remember, can not live without AntiForgeryToken()?
Thanks in advance.
Just in case it helps someone else who is novice like me in Java Script/JQuery.
The pagination logic in Java Script selects a page to display based on an index calculated through Index() method of JQuery and it considers number of form elements.
Since AntiForgeryToken() adds a hidden form element the index was wrongly calculated to 1 instead of 0 (for page 1). That was the role AntiForgeryToken() was playing.
The solution is to pass pagination group identifier to Index() method so it does not consider any other element than which belongs to pagination only.
That was it.
Learning from this problem, always be more specific while finding HTML elements with JQuery or any other JS library. JQuery did provide the means but unfortunately since things was working previously the original author did not utilized the power of Index() method.

Help : printing multiple "reports" from browser (IE 6 essential, others would be nice)

No thoughts on this one? Anyone?
Here is my scenario:
I have a form where the user selects a report type, and then selects a list of users they want to generate reports for. When they submit the form, a new window is opened that uses pagination to allow the user to review each user report individual by using next and previous links.
The user wants the option to:
print both the currently displayed report by itself (that's an easy one), and
a "print all" option to print all the selected reports.
However, each report for each user must have its own "Page x of n" footer.
For the footer, I have been using the browser footer options, but in order to have the page numbering start new on each report printout, I have to make a separate window.print() call for each one. I have implemented this this way, and it works, but it's awful because each print() call causes a new print dialog to display, meaning the user has to click print in each dialog to finalise the print request. Many reports = a stupid number of popped up print dialogs.
Ideally, I would like the printing of a report group to look like a single print job, but I need that page count to be restarted for each report.
I thought of trying to count pages myself to make my own footer, but that seemed like a daunting task considering all the variables that could affect how many pages a report would occupy. I also read some about using ActiveX and WebBrowser objects to force prints and hide the print dialog, but I have had no success with that because I am running on XP SP2. Also, I understand it's frowned upon from a security perspective, and it's not a good cross-browser solution.
Has anyone dealt with printing of this type before and would have some suggestions for a way to make this work or a better way to handle it?
Thanks in advance.
I've seen this done two ways the simplist using the MeadCo scriptx component which alows you to print without a dialog. But as you rightly say this is not good from a security perspective. This was done in a corporate environment where they had control over the end users browser.
The second would be to go down the ajax route and load each report page individually, without prining, then concat each report html together into one doucment adding any needed page breaks. Finally rendering to an IFRAME and calling print on that frame to print all reports in one action.
This isn't tremendously helpful, but you may want to look into using a pdf generator, such as PDFlib or fpdf. Doing this with static pages will incur all the problems you stated, as well as some which you didn't (such as the user setting his own font or font size and ruining your pagination).

Categories

Resources