Heya I am currently trying to tidy up my powershell universal pages. I use a data grid to display my data, before now I just inserted every grid column manually but I am trying to make that more efficient.
So I tried using this method with Get-Member and a for loop
The issue I am facing is that the conditions with the or operator for some reason every single one of them just takes the value of placeholder2 even the data in the elseif block. I was wondering if anyone had any insight on this? trying to debug EventData in the console does not give me much of a return.
Initially this seemed like an easier problem to parse than it ended up being. I’ll start with just showing you I’m accomplishing a similar (if simpler) case.
I have a datagrid with dynamic columns that I load like this:
# Get the columns as a raw NoteProperty[]
$DGPreColumns = $InputData | Get-Member -Type NoteProperty | Select-Object -ExpandProperty Name
# Create the actual column objects
$DGColumns = $DGPreColumns.forEach({
New-UDDataGridColumn -Field $_
})
Then, it’s splatted into New-UDDataGrid like so:
# Define a hashtable of properties to pass to the table
$DGProperties = @{
AutoHeight = $true;
Columns = $DGColumns;
Id = $Id;
LoadRows = { Out-UDDataGridData -Data $InputData -Context $EventData -TotalRows $Rows.Length };
ShowPagination = $True;
StripedRows = $True
}
# If we have some detail content, add it to the properties array
if ($DetailContent) {
$DGProperties.LoadDetailContent = $DetailContent
}
New-UDDataGrid @DGProperties
The main difference I’m seeing is that your -LoadRows never utilizes Out-UDDataGridData. However, I’m not sure what your issue is:
Is every $prop evaluated as if it were Placeholder2?
Is the data for each row only pulling from the Placeholder2 column (resulting in the same piece of information duplicated across each column for a given row)?
Is every column just Placeholder2, with the condition evaluating “correctly” as if it were Placeholder2?
Sorry if I’m not much help - let me know if there are any more specifics you can provide.
ZG
Interesting… can you Write-Debug (ConvertTo-Json $SqlSpalten) and see what it’s returning? That’s where I would start. Without access to your database it’s hard to try and troubleshoot from my end…