Hi all,
I've noticed a diffrence in the result between when I set a filter and sort via the DataSet object in the Wix Editor ans when I set them in Wix Code.
When I set the Sort and Filter on the object in the Wix Editor the filter and sort is applied to the returned items immediatly on page load.
When I set the Sort and Filter in Wix Code, and load the page, everything is returned intially, and after a second or so I see the filter and sort being applied. It could be that i'm not following best practice in my code?
import wixData from 'wix-data';
$w.onReady(function () {
$w("#dataset").onReady(() => {
$w("#dataset").setFilter(wixData.filter().eq("published", true));
$w("#dataset").setSort(wixData.sort().ascending("pubdate"));
// ...
});
});
I'm wondering if anyone else has experianced this?
I have this same issue, did anybody find a solution to this?
Hi! I am having the same problem with my site - I have the dataset filtered on some values using the dataset object ui, but I need to filter by date which is only possible in code.
Were you able to come up with a good solution to this?
Is there no way to filter the dataset with code before the page loads "on ready"?
The alternative is coding a "loading" icon and hiding the repeaters until the dataset is filtered? Any tips on how to do this without slowing down the page even more?
Hi Moshe, great suggestion. I had thought about doing this also, however, this adds delays to displaying content that isn't needed when setting the sort and filter on the dataset object in the editor.
I would love a solution to this issue that doesn't require hiding elements until the sort and and filter returns, at least, I don't feel I should have to do this as the developer.
But if this is the only approach I guess i'll have to go this way.
I suggest hiding the table until filtering and sorting is done.
both filtering and sorting return promises so its fairly easy to wait for both to finish.
Thanks Roi. Any ideas why the full dataset seems to load and then filter and sort? Should the filter and sort happen prior to tje dataset being ready?
Hi,
Your code looks ok.
Roi.