Dataview event on load

if a dataview returns only 1 result can we have it select it?

Absolutely! I’ve created a snippet that shows it being done. I had to do it just as basic code in the snippet because the parse() function doesn’t return a promise object like the load() function does, but the idea is the same. You can just move the IF block inside the .then() or .finally() portion of your load. Something like this:

 dataview.data.load("/your/url").finally(function(){
    if (dataview.data.getLength() === 1){
        var id = dataview.data.getId(0);
        dataview.selection.add(id);
    }
 });
2 Likes

THanks @kcasarez your solution worked perfectly.