Can’t set display dataset properly

So i have this text (text7) which supposed to show the price of the item which i created in the collection using number field… but it seems when i ran it on preview / live site it only shows 0 not the actual numbers that i put in the collection… is there anything wrong with my code? (i’m using the code to get the numbers to show up in 000,000,000 format)

i got the code from https://www.wix.com/velo/forum/tips-tutorials-examples/format-numbers-coming-out-from-dataset (i already installed numeral.js)

Regarding your pic → your code seems to be a little bit CHAOTIC.
Perhaps you should provide your code in a well and good looking CODE-BLOCK.

like this example…

My CODE in a CODE-BLOCKE here....

Why you should do that?

COUNTER-QUESTION: Why we should do that for you? Why i should waste my time to RETYPE all your CODE from a screen-pic???

okay sorry for the confusion, here’s my code… the first part which is the “Number Format” is the one which i’m unable to get it work properly… the second part “Filter by name & price” is already working the way i want to… can you locate my mistake? thank you!


// Number Format
import numeral from "numeral";

export function teamRepeater_itemReady($item, itemData, event) {
    let currentItem = $w("#teamDataset").getCurrentItem
    let views = currentItem.views
    $w("#text7").text = numeral("mulai").format("0,0")

}

// Filter by name & price
import wixData from 'wix-data';

$w.onReady(function () {
    $w("#dropdown1").onChange(() => {

        let dropdownVal = $w("#dropdown1").value;

        //OPTIONS 
        if (dropdownVal === "Nama A-Z") { $w("#teamDataset").setSort(wixData.sort().ascending("title")) }

        if (dropdownVal === "Nama Z-A") { $w("#teamDataset").setSort(wixData.sort().descending("title")) }

        if (dropdownVal === "Harga Terendah") { $w("#teamDataset").setSort(wixData.sort().ascending("mulai")) }

        if (dropdownVal === "Harga Tertinggi") { $w("#teamDataset").setSort(wixData.sort().descending("mulai")) }
    });

});


You should use the Repeated Item Scope , that is: $item, and not $w

export function teamRepeater_itemReady($item, itemData, event) {
    let currentItem = $item("#teamDataset").getCurrentItem();
    let views = currentItem.views;
    $item("#text7").text = numeral("mulai").format("0,0");
}

Also, you probably don’t need to get the dataset’s current item, since the data is already being passed in itemData. You should be able to do something like this:

export function teamRepeater_itemReady($item, itemData, event) {
let views = itemData.views;
$item(“#text7”).text = numeral(“mulai”).format(“0,0”);
}

Note: all import statements should appear at the beginning of the file.

@reymcfc
And as you can see you already got your answer, i was not even fast enough!
So, in future always show directly your current (not working code), detail description included and you will get your answer.

@yisrael-wix thanks a lot man!! it works perfectly

@russian-dima thanks man… i’m pretty new to Wix so… sorry for the inconvenience! i’ll use code block next time

Hi Reyhan,

getCurrentItem( ) is a function, and you’re assigning the function as the value of your " currentItem " variable, while you need to assign the value returned from the function as your variable’s value, so you need to call the function by adding the parentheses after the function name.

// It should be:
const currentItem = $w('#teamDataset').getCurrentItem();

// Instead of:
let currentItem = $w('#teamDataset').getCurrentItem;

Hope this helps~!
Ahmad

And please note:

You should share your code in code blocks as I did in my answer, it’s against the community guidelines to share your code in screenshots as it’s harder to us to see and extract the code from it.

Screenshots for other things are still recommended :+1:

@yisrael-wix good catch, I had an eye strains from the screenshot :joy: