jamir88
September 1, 2023, 11:08am
1
I am having trouble with New-UDTableColumn -Render having New-UDSelect, the selections are showing however it does not update the actual value. The output still is set to the default value and not the one I selected on the New-UDSelect items. I am still new and learning so may be a problem with how I update or sync the udelement. Please help. Thanks.
$Columns = @(
New-UDTableColumn -Property CatalogName -Title CatalogName
New-UDTableColumn -id 'element_cloneimage' -Property CloneImage -Title CloneImage -Render {
$cloneimagevalue = $eventdata.CloneImage
$cloneimagename = $cloneimagevalue.name
$basetablefilter = $basetable | where {$_ -match $cloneimagename}
New-UDSelect -id Select_$($EventData.CloneImage) -Option {
foreach ($basename1 in $basetablefilter) {
New-UDSelectOption -Name $basename1 -Value $basename1
}
} -DefaultValue $cloneimagename -OnChange {
Sync-UDElement -id 'element_cloneimage'
}
}
jamir88
September 5, 2023, 8:43am
2
Any one care to answer my problem, I need this to work. Thanks in advance.
Can you provide the rest of your code that has the New-UDTable?
What is the goal?
@jamir88 Is the goal to have a column in a table that only updates that specific row when a drop down selection is made?
jamir88
September 12, 2023, 3:39am
6
@kevinblumenfeld that is correct. There is a defaultvalue set. But when I try to make a selection, it does not update the specific row, when I proceed to create the table, the row still contains the defaultvalue instead of the selection I made.
jamir88
September 12, 2023, 3:40am
7
$Columns = @(
New-UDTableColumn -Property CatalogName -Title CatalogName
New-UDTableColumn -id 'element_cloneimage' -Property CloneImage -Title CloneImage -Render {
$cloneimagevalue = $eventdata.CloneImage
$cloneimagevalue = $cloneimagevalue.name
$cloneimagename = $eventdata.Baseimage
$basetablefilter = $basetable | where {$_ -match $cloneimagename}
$active_catalog = $eventdata.catalogname
New-UDSelect -id "Select_$($EventData.CloneImage)" -Option {
foreach ($basename1 in $basetablefilter) {
New-UDSelectOption -Name $basename1 -Value $basename1
}
} -DefaultValue $cloneimagevalue -OnChange {
Sync-UDElement -Id 'Rollout'
Show-UDToast -Message "$EventData[0]"
($mcupdatelist | where catalogname -eq $active_catalog).cloneimage = $EventData[0]
}
}
New-UDTableColumn -Id 'element_snapshot' -Property SnapShot -Title SnapShot -Render {
$cloneimagevalue = $eventdata.Baseimage
$snapshottablefilter = $snapshottable | where name -match $cloneimagevalue
$active_catalog = $eventdata.catalogname
New-UDSelect -id "Selected_snapshot" -Option {
foreach ($baseinfo in $snapshottablefilter ) {
$snapshotinfo = $baseinfo.name
New-UDSelectOption -Name $snapshotinfo -Value $snapshotinfo
}
} -DefaultValue $eventdata.snapshot -OnChange {
Sync-UDElement -Id 'Rollout'
Show-UDToast -Message "$EventData[0]"
($mcupdatelist | where catalogname -eq $active_catalog).snapshot = $Eventdata[0]
}
}
New-UDTableColumn -Property BaseImage -Title BaseImage
New-UDTableColumn -Property StorageResource -Title StorageResource
New-UDTableColumn -Property HostResource -Title HostResource
New-UDTableColumn -Property Engineer -Title Engineer
)
New-UDTable -Id 'mcupdate_table' -Data $mcupdatelist -Columns $Columns -Title 'Clone and Snapshot Table' -ShowSearch -ShowPagination -ShowSelection -Dense -OnRowSelection {
$mcupdate_table = (Get-UDElement -Id 'mcupdate_table').selectedRows
$Item = $EventData
Show-UDToast -Message "$($Item | out-string)" -Duration 10000
}
$Columns = @(
New-UDTableColumn -Property CatalogName -Title CatalogName
New-UDTableColumn -id 'element_cloneimage' -Property CloneImage -Title CloneImage -Render {
$cloneimagevalue = $eventdata.CloneImage
$cloneimagevalue = $cloneimagevalue.name
$cloneimagename = $eventdata.Baseimage
$basetablefilter = $basetable | where { $_ -match $cloneimagename }
$active_catalog = $eventdata.catalogname
New-UDSelect -id "Select_$($EventData.CloneImage)" -Option {
foreach ($basename1 in $basetablefilter) {
New-UDSelectOption -Name $basename1 -Value $basename1
}
} -DefaultValue $cloneimagevalue -OnChange {
Sync-UDElement -Id 'Rollout'
Show-UDToast -Message "$EventData[0]"
($mcupdatelist | where catalogname -eq $active_catalog).cloneimage = $EventData[0]
}
}
New-UDTableColumn -Id 'element_snapshot' -Property SnapShot -Title SnapShot -Render {
$cloneimagevalue = $eventdata.Baseimage
$snapshottablefilter = $snapshottable | where name -match $cloneimagevalue
$active_catalog = $eventdata.catalogname
New-UDSelect -id "Selected_snapshot" -Option {
foreach ($baseinfo in $snapshottablefilter ) {
$snapshotinfo = $baseinfo.name
New-UDSelectOption -Name $snapshotinfo -Value $snapshotinfo
}
} -DefaultValue $eventdata.snapshot -OnChange {
Sync-UDElement -Id 'Rollout'
Show-UDToast -Message "$EventData[0]"
($mcupdatelist | where catalogname -eq $active_catalog).snapshot = $Eventdata[0]
}
}
New-UDTableColumn -Property BaseImage -Title BaseImage
New-UDTableColumn -Property StorageResource -Title StorageResource
New-UDTableColumn -Property HostResource -Title HostResource
New-UDTableColumn -Property Engineer -Title Engineer
)
New-UDTable -Id 'mcupdate_table' -Data $mcupdatelist -Columns $Columns -Title 'Clone and Snapshot Table' -ShowSearch -ShowPagination -ShowSelection -Dense -OnRowSelection {
$mcupdate_table = (Get-UDElement -Id 'mcupdate_table').selectedRows
$Item = $EventData
Show-UDToast -Message "$($Item | out-string)" -Duration 10000
}
Did you see an example where New-UDTableColumn -ID 'Test'
was being used with Sync-UDElement
?
Also what version are you on?
jamir88
September 12, 2023, 4:54am
11
No, I just experimented with different components because I could not figure out how to. Version is 3.9.5
@jamir88 I’m unsure if it’s possible to ascertain from which row a UDSelect is invoked. As of now, I haven’t stumbled upon a method to achieve this. That said, the -OnRowSelection
feature might help. Additionally, while the sample code can shed some light, a visual representation—maybe in the form of a spreadsheet—showcasing your desired result before and after might be helpful. I used -LoadData
, but feel free to stick to your approach. Since I frequently work with databases, I based my examples on them, using them as a template.
$Page:Data = foreach ($Item in (0..2)) {
$Item = $Item.ToString()
@{
Col1 = $Item
Col2 = $Item
Col3 = $Item
}
}
New-UDTable -Id 'Table' -LoadData {
$TableData = ConvertFrom-Json $Body
$Page:Data | Out-UDTableData -Page $TableData.page -TotalCount $Count.count -Properties $TableData.properties
} -Columns @(
New-UDTableColumn -Property 'Col1' -Title 'Col1'
New-UDTableColumn -Property 'Col2' -Title 'Col2'
New-UDTableColumn -Property 'Col3' -Title 'Col3'
New-UDTableColumn -Property 'CloneImage' -Title 'CloneImage' -Render {
Show-UDToast ('$EventData {0}' -f ([PSCustomObject]$EventData | Select-Object *) | Out-String) -Duration 10000
New-UDSelect -Id "Select_$($EventData.Col1)" -DefaultValue '3' -Option {
foreach ($Item in (3..9)) {
$Item = $Item.ToString()
New-UDSelectOption -Name $Item -Value $Item
}
} -OnChange {
Show-UDToast ('Was Selected with UDSelect:{0}. Row(s) Selected with checkboxes (Would need to be implemented): {1} ' -f $EventData[0], $Page:SelectedRows) -Duration 10000
$Page:Data = foreach ($Item in $Page:Data) {
@{
Col1 = $EventData[0]
Col2 = $Item.Col2
Col3 = $Item.Col3
}
}
Sync-UDElement -id 'Table'
}
}
) -ShowSelection -OnRowSelection {
$Page:Table = Get-UDElement -Id "Table"
$Page:SelectedRows = $Page:Table.selectedRows
}
This post shows how to retrieve the UDSelect
value from each selected row in a UDTable
Product: PowerShell Universal
Version: 3.0.6
Hello,
I have a UDTable using columns, 1 column has rendering using a UDSelect. The table also has selections enabled for the rows. I know how to get the selected rows details, but how can I get the UDSelect value from each selected row?
Thanks for any help!
Hope this helps.
jamir88
September 14, 2023, 8:12am
13
@kevinblumenfeld thans for your suggestion. I am trying it out but no data was populating. Where did you get this data?
$TableData = ConvertFrom-Json $Body
Can you show me the content?
Can you provide code that you are trying. All data is there. It’s just sample numbers in $Page:Data