Get current page number in ng-tables - ngtable

How to get current page number the user is seeing? And when the table is refreshed it can land him on the same page instead of specifying 1st page always.

To get the current page number use: this.tableParams.page()
To set the page number use: this.tableParams.page(3)
You will need to change 'tableParams' with whatever your table object is called.
Also be mindful that if your data is dynamic and you set the page to something out of the max page range then the data will just not show.

Related

Spring JPA : how can i get the last Page of an object when I do not know the total number of page

I am trying to get the total number of pages for my Object, so that i would be able to call the last page. This was the code i used
Page<Message> firstPage = defaultMessageService.getMessage(user, user2, new PageRequest(0, 6));
paginationModel.setMessagesPage(defaultMessageService.getMessage(user, user2, new PageRequest(firstPage.getTotalPages() - 1, 6)))
.setResponseMessage("Successful")
.setSuccessful(true);
in my code i called the first page, just to get the total number of pages and subtracted the the total pages by one, to get the last page. This is resource taking as i get the list of content with the page, contents i dont intend to use. Is there a better way ? i just want the total page, size, current page
if you want only last page then sort your data in descending order and then get the first page. is it possible to sort your data then your problem will be solved.

iTextSharp table cell content only display complete content in second page directly due to long content

I had search some relative question which had been asked, but seem not too much my condition.
My problem is simpler to this problem
Table in iTextSharp is not page breaking as desired?
The different between my problem and his is I need header in each extend page.
Currently I put a long table in one of cell, it make me has header in each page, but if the table to long, all table will shift to second page, and first page is empty.
I have tried table.KeepRowsTogether, but the 15 rows stay in second page and rest in third..
I determine what is the length of list. if number of items more than 15 then I separate list into 0 ~ 14 and 15th to the end, keep all content in the same table then there will having header in second page. Case close

Load only first 10 posts, then load more - parse.com

I'm having a post-feed where I load my posts from a parse database. All posts are saved and loaded from one class.
Now, when the app launches and the user opened the post-feed, I want to load only the first 10 posts (sorted by date).
After that, when I'm at the bottom table cell, I want to load the next 10 posts. Can be done by pressing a "Load More" button or by scrolling at the bottom and it automatically loads more.
I use swift in xCode.
Can anyone help me with that?
PFQuery has a limit property and a skip property.
These are listed in the docs under "Paginating Results".
For the first ten you set skip to 0 and limit to 10.
For the next ten you set skip to 10 and limit to 10.
And so on...
You can read more detail by looking at the documentation for PFQuery.
To add your results to the existing results.
First have an array to store the results.
var results = [MyObject]()
Then when the results come back from parse currently you will be doing something like this...
results = theArrayReturnedFromParse
This will set the array to be only the ten from parse. You need to do this...
results += theArrayReturnedFromParse
This will add the new results to the array and keep the old ones.

iTextSharp - finding end of page

Is there any way to find the current page is going to end in iTextSharp. For example,
say there are some 10 records which needs two pages to be written down at the end of the first page i wish to add '(contd on nex page'). IS there a way to do this. Will finding the end of page be an answer for this or is there a way to find the line number on which writing is done, so that i can make a calculation to decide whether to add a message of my choice and proceed to the next page.
any advise is much appreciated :)
Thanks a zillion
Usually, this is done by defining a footer for the table. When the table breaks automatically, iText will show that footer. Of course: you don't want this footer to show up on the last page (after the final row of the table). That's why there's also a method to skip the last row.
This example shows you how to create a table with headers and footers. This is the link to SkipLastFooter.
Note that saying that "finding the line number" would solve your problem is wrong for two reasons:
There is no such thing as a line number in a PDF file. You have a MediaBox and you draw content on the canvas defined by the MediaBox using coordinates.
There's a way to get the current Y-position on a page after adding an object to a document. You can get the Y-position before adding a table and after adding a table, but not while you're still creating the table.
An alternative solution to the one I suggested above, woult be to use table events.
If you really need to find the end of the page, and are not using a table with a footer row that will be printed at the end of each page, you can use the PdfWriter object as follows:
var remainingPageSpace = pdfWriter.GetVerticalPosition(false) - pdfDocument.BottomMargin;
This will give you the remaining space on the page, from which you can determine what you want to do next.
If you are using tabular data however, it is much preferred to use a PdfPTable and take advantage of the footer row feature.

iTextSharp and moving some data to next page

I am creating an invoice using the iTextSharp. That displays nicely but sometime, when invoice items are larger in qty, the summary portion (which displays subtotal, tax, discounts, grand total etc) is splitted. Some displayes in current page and some moves to next page. I was thinking to move entire summary portion into next page, if current height left is not enough for that.
However, to do that, I need to know that how much page height is left (after my current page content rendering). I wonder if someone know how to calculate current left height of the page? OR if there is a property in the pdfPTable which may force the table to print itself as a whole and dont let it split across multiple pages! I guess if second option is available, it will be easy.
In summary, I need to know if it is possible to calculate remaining page height, and also if that is possible to force a table to NOT split across multiple pages.
thank you.
Sameers
You can set SplitLate to false to avoid auto page break in a cell data exceeds limit.
......
table.addCell(cellData);
table.SplitLate = false;
......
I suggest you use a nested table for your summary section. I don't believe iText will split a given cell on a page boundary, so everything in that cell (even if its a nested table with cells of its own) will stay on the same page.
Use the table's cell's row span so it takes up an entire row on its own.
I'm not certain, but I'd wager a beer on it.
What object are you using to add your data to the PDF? MultiColumnText, Paragraph, Phrase?
You should be able to use Document.PageSize.Height property to return the height of the Page.
Then use PDFPTable.Height to return the height of your table.
So just use the logic Document.PageSize.Height - table.Height, and you'll have the remaining y-axis space available.
The PDFPTable object has properties named SplitLate and SplitRows. I believe you can use these properties to try and keep the table on one page.