Syncing UD component and custom javascript

Hello UD experts,

I am trying to implement select all in udgrid. I was able to implement it using custom javascript code:

New-UDButton -Text "Select All" -OnClick (
    New-UDEndpoint -Endpoint {
        Invoke-UDJavaScript -Javascript "
var checkboxes = document.querySelectorAll('#$gridId input[type=""checkbox""]');
for (var i = 0; i < checkboxes.length; i++) {
    checkboxes[i].checked = false;
    
}
for (var i = 0; i < checkboxes.length; i++) {
    checkboxes[i].click();
}
        "
    }
)

New-UDButton -Text "Deselect All" -OnClick (
    New-UDEndpoint -Endpoint {
        Invoke-UDJavaScript -Javascript "
var checkboxes = document.querySelectorAll('#$gridId input[type=""checkbox""]');
for (var i = 0; i < checkboxes.length; i++) {
    checkboxes[i].checked = true;
    
}
for (var i = 0; i < checkboxes.length; i++) {
    checkboxes[i].click();
}
        "
    }
)

However, the behavior is quite laggy, as each checkbox has its own endpoint and I need to wait till all endpoints are executed - see the demo.

Is there a way to get from UD the changed component by JS(Avoiding to call all the endpoints)?

Thanks!

Any comments on the above?
If it is not possible, will be a good answer as well :slight_smile:

You’ve come up with a pretty crafty solution! I don’t know if there is a better way.

I’m going to add select functionality directly to New-UDTable in UDv3 so you won’t have to do this work around.

1 Like

Thank you very much, Adam!