Dynamic

Dynamic component for portal components.

The dynamic component allows you to run PowerShell script to generate PSBlazor components on the fly. It's context aware.

Because dynamic components run PowerShell with each render, they can reduce the performance of your apps.

A dynamic component is defined with a function that will be executed when the app is loaded.

<Dynamic Function="RenderMyDynamic" />

Within the dynamic, return a string that will be rendered. It must be valid PSBlazor syntax.

function RenderMyDynamic {
    "<Alert Message='Cool!' />"
}

If you are using a dynamic within a component that sets a context variable, you can use the context in your function. In this example, we have a table of services that uses a dynamic in the status column.

<Table DataSource="$Services">
    <PropertyColumn Property="Name" />
    <PropertyColumn Property="Status">
        <Dynamic Function="RenderStatusColumn" />
    </PropertyColumn>
</Table>

The function RenderStatusColumn will be called for each row in the table.

function RenderStatusColumn {
    param($Context)
    
    if ($Context.Status -eq 'Running')
    {
        "<Alert Message='Started' />"
    }
    else 
    {
        "<Alert Message='$($Context.Status)' />"
    }
}

Last updated

PowerShell Universal

DownloadsPricingModules

Community

IssuesForums

Copyright 2024 Ironman Software