Hey there. I have this code I use to display numbers with comma separators and $ symbol. One code is for a table and another code is for a repeater. Both the repeater and the table have a Load More button however when I click it to load more info the code doesent work anymore so the info is displayed without the comma separators etc. Any help? Sorry if my code is a mess…not a pro
CODE FOR TABLE:
$w.onReady( function () {
$w( “#dataset2” ).onReady(() => {
let rows = $w( “#table1” ).rows;
let count = $w( “#table1” ).rows.length;
for ( let i = 0 ; i < count; i++) {
let oldScore = rows[i][ “price” ]
console.log( "old score is " + oldScore);
var number = Number(oldScore)
console.log( "revised score is " + number.toLocaleString());
let revisedScore = number.toLocaleString();
rows[i][ “price” ] = ‘$’ +revisedScore;
}
$w( ‘#table1’ ).rows = rows
})
$w( “#dataset2” ).onReady(() => {
let rows = $w( “#table1” ).rows;
let count = $w( “#table1” ).rows.length;
for ( let i = 0 ; i < count; i++) {
let viejoScore = rows[i][ “precioArriendo” ]
console.log( "viejo score is " + viejoScore);
var number = Number(viejoScore)
console.log( "revised score is " + number.toLocaleString());
let revisadoScore = number.toLocaleString();
rows[i][ “precioArriendo” ] = ‘$’ +revisadoScore;
}
$w( ‘#table1’ ).rows = rows
})
})
CODE FOR REPEATER:
$w.onReady(() => {
$w( ‘#dataset1’ ).onReady(() => {
$w( ‘#propertiesRepeater’ ).forEachItem( ($w, itemData, index) => {
const numberWithCommas = (x) => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, “.” );
}
$w( ‘#text58’ ).text = numberWithCommas(parseInt($w( ‘#text58’ ).text));
$w( ‘#price’ ).text = numberWithCommas(parseInt($w( ‘#price’ ).text));
} );
});
$w( "#propertiesRepeater" ).onItemReady( () => {
$w( “#propertiesRepeater” ).forEachItem( ($item, itemData, index) => {
if ( $item( ‘#statusText’ ).text === “Arriendo” ) {
$item( ‘#text57’ ).show();
$item( ‘#text58’ ).show();
$item( ‘#text59’ ).show();
$item( ‘#text60’ ).hide();
$item( ‘#text46’ ).hide();
$item( ‘#price’ ).hide();
}
}
);
});
$w( “#dataset1” ).onReady( () => {
$w( “#propertiesRepeater” ).onItemReady( () => {
$w( “#propertiesRepeater” ).forEachItem( ($item, itemData, index) => {
if ( $item( ‘#statusText’ ).text === “Venta” ) {
$item( ‘#text57’ ).hide();
$item( ‘#text58’ ).hide();
$item( ‘#text59’ ).hide();
$item( ‘#text60’ ).show();
$item( ‘#text46’ ).show();
$item( ‘#price’ ).show();
}
}
);
});
});
});