How to show the second item from a Dataset that is set to sort data from highest to lowest value?

Hi! I have this code right now but it only show the first item from the sorting. :confused:

$w.onReady(() => {
    const dataset = $w("#dataset1");
        dataset.onReady(() => {
            const { title , nbMatchJoues } = dataset.getCurrentItem();
                $w("#text203").text = `2. ${title} (${nbMatchJoues})`;
        });
});

How can I get the second item to show , or any other one ?

Thanks ! :slight_smile:

To get a specific field only then change your code to suit.
getCurrentItem().field;
Although note that with getCurrentItem you are only getting the dataset’s current item in return.

As shown in the Wix API Reference for getCurrentItem .
Examples
Get the dataset’s current item

let itemObj = $w("#myDataset").getCurrentItem();

/*  
 *  {
 *    "_id":                "fcec780a-3e37-4b64-8a66-37c552c53f99",
 *    "_owner":             "f6c0f9c3-a62d-7e9f-g58d-943829af244d9",
 *    "_createdDate":       "2017-05-01T17:19:03.823Z",
 *    "_updatedDate":       "2017-05-01T17:19:10.477Z",
 *    "title":              "Dr. ",
 *    "name":               "B",
 *    "link-dynamic-name":  "/myCollection/B"
 *  }
 */

If you want to find a specific item from a dataset field which might not be the current item, then you will need to query that field to find it.

Well, I have been trying to get this to work for about 5 hour now… still not working. Am I suppose to work with getCurrentItem or DataQuery?

$w.onReady(() => {
    const dataset = $w("#dataset1");
        dataset.onReady(() => {
            const { title , nbMatchJoues } = dataset.getCurrentItem();
                $w("#text197").text = `2. ${title} (${nbMatchJoues})`;
        });
});

Can you please help me getting started? Assuming my dataset1 is already sorting from highest to lowest, I need the second item from the “title” and “nbMatchJoues” column to show in the box #text197.

Nevermind. I did this with getItems() instead.

$w.onReady( () => {
$w("#dataset1").getItems(0, 3)
.then( (result) => {
let items = result.items;
$w("#text144").html = `<p style="text-align:center"><span style="font-size:40px"><span style="font-family:Anton"><span style="color:white">${items[0].nbMatchJoues}</span></p>`;
$w("#text185").text = `1. ${items[0].title}`;
$w("#text197").text = `2. ${items[1].title} (${items[1].nbMatchJoues})`;
$w("#text198").text = `3. ${items[2].title} (${items[2].nbMatchJoues})`;
});
});