chana
May 14, 2019, 11:40am
1
I know that it is a common question, but i can’t find a solution.
I have Table1 with fields Field1 and Field2. Field2 is a reference field to Table2.
Table2 have Field3 and Field4. I want to sort my dataset which connected to Table1 by Table2.Field4 field.
It doesn’t work. Please help!
$w(“#dataset1 ”).setSort( wixData.sort()
.ascending(“Table2.Field4”)
)
.then( () => {
console.log(“Dataset is now sorted”);
} )
. catch ( (err) => {
console.log(err);
} );
chana
May 21, 2019, 8:14am
3
I did found out i can do it with .include:
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#include
However, despite a am getting now refrenced fields in my query results, it seems that it is not sorted…
function GetSelectedFields(){
wixData.query(“EventSelectedFields”)
.include(“selectedField”)
.descending(“selectedField.cefName”)
.find()
.then( (res) => {
if (res.items.length > 0) {
let items = res.items;
$w(‘#tableTest ’).rows = items;
} **else** {
// handle case where no matching items found
console.log(“no items found”);
}
} )
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
console.log(errorMsg);
} );
}
No difference if i use .descending or .ascending, i see the items in my table in same order
@yoav-wix can you help?
Did you ever find a fix for sorting?