Currently you can paginate towards the backend, with the next and previous option, but I can't do it with the rows per page option, how do I make the two options work? Thank you
Here is an image of the options
For paging you need:
know the number of records.
number of records displayed on page.
page number.
Send to server from client: number of records on page and page number)
Send to client from server: records between from, to
const count = 20; // for example we have 20 records
const size = 7; // there are 7 records on each page
// number of pages
const countPages = Math.ceil (20/7);
//show records on page 2:
const page = 2; // display 2nd page
const from = (page - 1) * size;
const to = Math.min (from + size- 1, count);
console.log(`we have ${count} records, ${size} per page` )
console.log('number of pages', countPages);
console.log(`on page ${page} records from ${from} to ${to}`);
Related
I created a content element in TYPO3 (Ver. 11.5.9).
Now I want to finish my HTML-files with Fluid. But I can't display my data from my table of a database.
The Backend of the content element seems like so:
In a content element there are two tabs and in every tab I can add some child items.
My table in a database is so:
tt_content
tx_anreisetag_item (this is a table for a tab of Anreisetag)
tx_abreisetag_item (this is a table for a tab of Abreisetag)
The data of the child items are saved in the tablestx_anreisetag_item and tx_abreisetag_item.
I added three records in Anreisetag and two records in Abreisetag. But if I check a debug in the frontend, then I can see just two records of Abreisetag. I can't find no object of Anreisetag:
In typoscript I wrote this codes:
tt_content.klassenfahrt_anundabreisetag >
tt_content.klassenfahrt_anundabreisetag =< lib.contentElement
tt_content.klassenfahrt_anundabreisetag {
templateName = AnundAbreisetag
dataProcessing {
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
table = tx_anreisetag_item
pidInList.field = pid
where {
data = field:uid
intval = 1
wrap = tt_content=|
}
orderBy = sorting
}
30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = tx_abreisetag_item
pidInList.field = pid
where {
data = field:uid
intval = 1
wrap = tt_content=|
}
orderBy = sorting
}
40 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
40 {
references.fieldName = tx_anreisetag_image
as = imageAnreise
}
50 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
50 {
references.fieldName = tx_abreisetag_image
as = imageAbreise
}
}
}
How can I register my another records of Anreisetag?
I hope someone can help me. Thank you.
You need to tell the DatabaseQueryProcessor the name of the records.
If you don't add
as = abreisetag
and also for the other call, both queries are stored in the variable named records. Then the first query will be overwritten by the second query.
Small hint: Use english variables.
I can't be sure as you have not provided your TCA and SQL declaration, but I assume you accessed the record with the uid, that is the count of relations.
TYPO3 inserts a field with the count of records, where the record relation is stored either in the related record (as a back link) or in mm-records.
In the given example, I have two lines to be displayed and datasets/time series data records for them are here dataset1: mock-data/i.js & dataset2: mock-data/iv.
Time range is between 2015 to 2021 years. In each data set there are around 60K to 70K records.
In reality it would be millions of records in each dataset and there will be multiple dataset/lines(40 to 60 datasets/lines).
Question: 1The part which I don't understand is, when I load the chart for the first time, which data should I display ??????? (as there are many records in the dataset)
I checked highcharts example: https://www.highcharts.com/demo/stock/lazy-loading and I feel like, from given time range, it shows each month's first date data when being loaded for the first time.
function getInitialDataPointsFromBackEnd() {
const onLoadDataset = [];
let timestamp;
for (let i = 0; i < dataset.length; i++) {
const { name, datapoints } = dataset[i];
const tempDataset = { name: name, datapoints: [] };
for (let j = 0; j < datapoints.length; j++) {
// push 0th record blindly to onLoadDataset
if (j === 0) {
tempDataset.datapoints.push(datapoints[j]);
timestamp = datapoints[j][0];
timestamp = timestamp + 2.628e9; // timestamp with one month difference
}
// push last record blindly to onLoadDataset
if (j === datapoints.length - 1) {
tempDataset.datapoints.push(datapoints[j]);
onLoadDataset.push(tempDataset);
}
// start finding next month timestamp record
const filteredMonthlyRecord = datapoints.find(
(x) => x[0] === timestamp
);
if (filteredMonthlyRecord) {
// if record is found increse time stamp by one month
timestamp = timestamp + 2.628e9; // timestamp with one month difference
tempDataset.datapoints.push(datapoints[j]);
}
}
}
return onLoadDataset;
}
So I'm trying to apply the similar kind of logic using getInitialDataPointsFromBackEnd function. Assume this is BE functionality or BE implementation in reality but just to make example more understandable I'm using in FE side, which should extract out each month's first record for given range(In my case time range is from 2011 to 2021).
But, since, in each dataset, there are around 60K to 70K records, I have to loop through all of them and prepare my first-load data.
This is very time consuming process. If I have 60 to 70 datasets and from each dataset If I have to extract out each month record, it will take forever to serve the data to front-end.
I'm sure, I'm missing something or making some basic mistakes.
Please help me understand what should be the onLoad dataset if you have two time series datasets as shown below.
My efforts: https://stackblitz.com/edit/js-srglig?file=index.js
Question 2: Also, bottom navigator keeps on updating every time when you try to change the selection and redraws lines in wrong way. How can I fix it too ? Ideally it should not update lining part only scroll trasparent window should be updated. isn't it?
I'm working on a sheet to build a list of products to import into Shopify.
For this, I have a pdf of some basic data (that is irrelevant here) out of which I build a string to crawl the product supplier's website and format the data in a way suitable for import in Shopify.
The products have a varying number of images (1 - 8), so I'm trying to build my script in a way that if a product has more than one image, I am trying to add additional rows under it and add every image past the first into a new row.
Here is my code:
function iterateThroughRows() {
// get spreadsheet
const sheet = SpreadsheetApp.getActive().getSheetByName("MySheet");
const data = sheet.getDataRange().getValues();
// Loop over rows
data.forEach( (row, rowIndex) => {
const imageSrcArray = [ /* list of image URLs, fetched from remote server */ ]
imageSrcArray.forEach( (img, arrayIndex) => {
if(arrayIndex == 0) { // for the first array item, just add it to the current row
const imageCell = sheet.getRange(rowIndex + 1, 24)
imageCell.setValue( imageSrcArray[arrayIndex] )
} else { // for each array item past the first one, add a new row and enter the value there
sheet.insertRows(rowIndex)
const imageCell = sheet.getRange(rowIndex + arrayIndex + 1, 24)
imageCell.setValue( imageSrcArray[arrayIndex] )
}
})
// adding some more values to other cells
});
}
As is this doesn't really work.
I worked on this all day yesterday and had a version using insertRowAfter() that did add additional rows, but added them all lumped together (i.e. there would be 15 rows after the first product, but none after any of the others). But since Google App Script doesn't have version control I lost that version.
I think the problem was that the forEach seems to move on to the newly created rows and keeps adding things from there rather than moving on to the initial next row.
So I'm more or less at the end of my wit with this. Any advise on how to properly do this would be highly appreciated.
I can understand your frustration, it is indeed because you care calculating the row based on the sheet in its version before you added new rows to it.
So my proposal would be to do this, as the currentRow allows you to track the current row you are working on. I also updated the insertRowAfter(), as I assume this is what you actually wanted to do.
let currentRow = 1;
data.forEach( (row, rowIndex) => {
const imageSrcArray = [ "img1URL", "img2URL"]
if( !imageSrcArray.length ) return
imageSrcArray.forEach( (img, arrayIndex) => {
if( arrayIndex == 0 ){
sheet.getRange(currentRow, 24).setValue( img )
} else {
sheet.insertRowAfter(currentRow)
sheet.getRange(currentRow+1, 24).setValue( img )
}
// New rows in between were created
currentRow++
})
});
When you load the first time, it shows correctly. After, each update gets 2 page view count, not one.
const Koa = require('koa');
const session = require('koa-session');
const app = new Koa();
app.keys = ['Shh, its a secret!'];
app.use(session(app));
app.use(async function(ctx) {
let n = ctx.session.views || 0;
ctx.session.views = ++n;
console.log(`times= ${n}`);
if (n === 1) {
ctx.body = 'Welcome here for the first time!';
} else {
ctx.body = `You visited this page ${n} times!`;
}
});
app.listen(3000);
Actually, I testet it right now and it seems to work correctly. What you have to consider, is, when typing your URL in the browser, some browsers already try to preload things. This also happened here.
What I then tried to be sure, that it works as expected: I shutted down the node/koa app, then in the browser cleared the session for that side (Developertools - Storage - Sessions), started node/koa app again and then on client side hit reload several times. Here, on server side I gut the correct output:
times= 1
times= 2
times= 3
times= 4
times= 5
and on client side the output was also correct.
Ok so I'm using routing to drill down into a specific item based on it's ID (but also capturing it's category)
$http.get('http://something.co.uk/?category='+$routeParams.storyCat+'&id='+$routeParams.storyID)
This gives a URL of http://website.co.uk/index.html#/category/103 with the story details coming from the data on the server based on the ID of the item you clicked.
The following functions are then run on swipe (using angular-touch) which increase or decrease the ID by one, showing the next or previous story.
$scope.nextStory = function () {
var storyID = Number($routeParams.storyID);
var storyCat = $routeParams.storyCat;
var path = '/' + storyCat + '/' + (storyID + 1 );
$location.path(path);
};
$scope.previousStory = function () {
var storyID = Number($routeParams.storyID);
var storyCat = $routeParams.storyCat;
var path = '/' + storyCat + '/' + (storyID - 1 );
$location.path(path);
};
The problem with this is that it literally just goes up and down the ID's. I need it to only go through ID's which match the Category of the item you are on.
For example if you click into story ID 95, which is in a category called "Bags" and then you swipe left, I need it to not simply show story 96 which might be in a different category, but instead find the next story within "Bags" and show that one.
Can this even be done using AngularJS and routing or do I need a completely different approach?