Users

All Posts (7)

avatar

rroberts

Can two New-UDSelect dropdowns be set up so the second updates dynamically based on the first selection?

avatar
avatar
avatar
avatar

Thanks Dynamic, I managed to work out another way of doing this, but I going to try out yourself and Ms-Marox solution as well

Can two New-UDSelect dropdowns be set up so the second updates dynamically based on the first selection?

avatar
avatar
avatar
avatar

Thanks Ms-Marox, this has been really helpful. I also managed to getting working using the following:

New-UDApp -Content {

$ClassType = @("Select Role", "Beginner", "Intermediate","Advance")

$beginners = @("Select Role", "B1", "B2","B3")

$intermediates = @("Select Role", "I1", "I2", "I3")

$advanced = @("Select Role", "A1", "A2", "A3")

$cources = @("Select Class")


New-UDSelect -Label 'Class' -Id 'selectClass' -DefaultValue $Classtype\[0\] -Option {

    foreach ($class in $classtype) {

        New-UDSelectOption -Name $class -Value $class

    }

} -OnChange {

    if ($Eventdata -eq "Beginner") {

        $cources = $beginners

        Clear-UDElement -Id 'addElement1'

        Add-UDElement -ParentId 'addElement1' -Content {

            New-UDSelect -Label 'beginners' -Id 'selectbeginners' -DefaultValue $cources\[0\] -Option {

                foreach ($cource in $cources) {

                    New-UDSelectOption -Name $cource -Value $cource

                }

            } -OnChange {

                Show-UDSnackbar -Message $EventData

            }

        }

    } elseif ($Eventdata -eq "Intermediate") {

        $cources = $Intermediates

        Clear-UDElement -Id 'addElement1'

        Add-UDElement -ParentId 'addElement1' -Content {

            New-UDSelect -Label 'intermediates' -Id 'selectIntermediates' -DefaultValue $cources\[0\] -Option {

                foreach ($cource in $cources) {

                    New-UDSelectOption -Name $cource -Value $cource

                }

            } -OnChange {

                Show-UDSnackbar -Message $EventData

            }

        }

    }

    else {

        \# Remove-UDElement -Id 'removeElement1'

        $cources = $advanced

        Clear-UDElement -Id 'addElement1'

        Add-UDElement -ParentId 'addElement1' -Content {

            New-UDSelect -Label 'Advanced' -Id 'selectadvanced' -DefaultValue $cources\[0\] -Option {

                foreach ($cource in $cources) {

                    New-UDSelectOption -Name $cource -Value $cource

                }

            } -OnChange {

                Show-UDSnackbar -Message $EventData

            }

        }

    }

}



New-UDElement -Tag 'div' -Id 'addElement1' -Content {}

New-UDSelect -Label '$Floors' -Id 'selectFloors' -DefaultValue $Floors\[0\] -Option {

    foreach ($Floor in $Floors) {

        New-UDSelectOption -Name $Floor -Value $Floor

    }

} -OnChange {

    Show-UDSnackbar -Message $EventData

}

}

Can two New-UDSelect dropdowns be set up so the second updates dynamically based on the first selection?

avatar
avatar
avatar
avatar

Hi,

Is it possible to create two dropdown menus using New-UDSelect, where the second dropdown updates dynamically based on the selection made in the first one? For example, if the first dropdown includes options like Beginner, Intermediate, and Advanced, selecting Beginner would display only the corresponding beginner options in the second dropdown, selecting Intermediate would show only intermediate options, and selecting Advanced would display only advanced options.

Disabling Stepper next button

avatar
avatar
avatar
Product: PowerShell Universal
Version: 5.5.5

I have created a Stepper with a number of fields, I have a validation script block which checks if the fields contain content. What I would like to do is disable the Next button if all the fields have not been validated as valid i.e., containing content.

Is there a way to do this?

Transition Visibility Not Updating Based on Selector Value After Navigation or Refresh

avatar
avatar
avatar
avatar

Hi,

Thanks for all your help, not quite what I wanted but useful all the same. Ms-Marox post works exactly how I wanted. But once again thanks for your help.

Transition Visibility Not Updating Based on Selector Value After Navigation or Refresh

avatar
avatar
avatar
avatar

Hi,

Thank you so much for your help this is exactly what I was trying to do.

Transition Visibility Not Updating Based on Selector Value After Navigation or Refresh

avatar
avatar
avatar
avatar
Product: PowerShell Universal
Version: 5.5

I have a stepper component with a selector and a textbox inside a transition. The textbox is shown or hidden based on the selected option.

The selector has two options: "staff" and "contractor". If "contractor" is selected, the Staff ID textbox should be hidden.

The issue is:

If I move to the next step and then go back, "contractor" is still selected, but the textbox is incorrectly visible.

The same happens if I refresh the page.

In both cases, the textbox appears even though the current selection should hide it.

New-UDApp -Content {
    New-UDStepper -Steps {
        New-UDStep -OnLoad {
            New-UDElement -Tag 'div' -Content { "Step 1" }
            New-UDTextbox -Id 'txtTicketNo' -Value $EventData.Context.txtTicketNo
        } -Label "Step 1"
        New-UDStep -OnLoad {
            New-UDElement -Tag 'div' -Content { "Step 2" }
            New-UDElement -Tag 'div' -Content { "Previous data: $Body" }
            
            $bodydata = $body | convertfrom-json
            Show-UDToast "Role is: $($bodydata.context.Role)"
            if ($bodydata.context.Role -eq 1) {
                    Set-UDElement -Id 'toggleStaffID' -Properties @{
                        in = $EventData -eq 'True'
                    }
                }
                else {
                    Set-UDElement -Id 'toggleStaffID' -Properties @{
                        in = 'false'
                    }
                }
            
            New-UDSelect -Id 'Role' -DefaultValue $EventData.Context.Role -Option {
                New-UDSelectOption -Name 'Staff' -Value 1
                New-UDSelectOption -Name 'Contractor' -Value 2
            } -OnChange {
                if ($EventData -eq 1) {
                    Show-UDToast $EventData
                    Set-UDElement -Id 'toggleStaffID' -Properties @{
                        in = $EventData -eq 'True'
                    }
                }
                else {
                    Set-UDElement -Id 'toggleStaffID' -Properties @{
                        in = 'false'
                    }
                }
            }
            New-UDTransition -Id 'toggleStaffID' -Content {
                New-UDTextbox -Id 'txtStaffID' -Value $EventData.Context.txtStaffID -Label 'Staff ID'
            } -Collapse -CollapseHeight 100 -Timeout 1000

        } -Label "Step 2"
        New-UDStep -OnLoad {
            New-UDElement -Tag 'div' -Content { "Step 3" }
            New-UDElement -Tag 'div' -Content { "Previous data: $Body" }
            New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
        } -Label "Step 3"
    } -OnFinish {
        New-UDTypography -Text 'Nice! You did it!' -Variant h3
        New-UDElement -Tag 'div' -Id 'result' -Content { $Body }
    }
}

1 - 7 of 7 items