I can set the dataset’s page size by buttons but i can’t set the page size from any input elements,
What i miss here ?
export function dropdown1_change(event) {
$w(“#dataset1”).setPageSize($w(‘#dropdown1’).value)
.then(() => {
console.log(“Page size set.”);
})
. catch ((err) => {
let errMsg = err.message;
let errCode = err.code;
});
}
Yes because the code will only work if the setPageSize is an integer (whole number)
Hence why it has the number 6 in the code sample in the API reference.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setPageSize
$w("#myDataset").setPageSize(6)
.then( () => {
console.log("Page size set.");
} )
.catch( (err) => {
let errMsg = err.message;
let errCode = err.code;
} );
Syntax
function setPageSize(pageSize: number): Promise<void>
PARAMETERS
pageSize - number
The new page size.
is there a way to convert the string value result of user input element to integer ?
i’ve figured it out, here’s my code if someone facing the same problem :
thanks for the help @givemeawhisky
//------------------------------------------------------------------------------------------------------------------------------------------------- Product Paging Element Setup //
function fillProductPagingDropdown() {
const productPagingDropdownOptions = [
{ “label”: “5 Products/Page”, “value”: “5” },
{ “label”: “10 Products/Page”, “value”: “10” },
{ “label”: “15 Products/Page”, “value”: “15” },
{ “label”: “20 Products/Page”, “value”: “20” }
];
$w(“#ProductPagingDropdownElt”).options = productPagingDropdownOptions;
}
function translateProductPagingDropdown() {
let desiredSize = $w(‘#ProductPagingDropdownElt’).value
let translateIt = parseInt(desiredSize)
if (isNaN(translateIt)) { return 0 }
return translateIt;
}
//---------------------------------------------------------------------------------------------------------------------------------------------- Product Paging Element Function //
export function ProductPagingDropdownElt_change(event) {
let productsPerPage = translateProductPagingDropdown()
$w(“#dataset1”).setPageSize(productsPerPage)
}
@abronson Yes of course!
Go to Google.com and search for: javascript string to integer
@benibrodi just did it a minute ago, but maybe if you have any idea to make my code shorter it would be greatly appreciated
@abronson A yes I see. Great you found the method parseInt .
Nope, I don’t see that it would be necessary to shorten your code. Of course I could use some advanced Engineering-Tricks but it looks good so far and I think it’s easyer to read for “beginners” 
(…only what I would to is using always const instead of let when possible… but that is here in Wix absolutly ok without)