Product: PowerShell Universal
Version: 3.2.6
Heyas, just using the example from Data Grid - PowerShell Universal and the filters added to the WHERE condition were coming in as Param0 and Param1 etc instead of the values added to the filters.
I changed the instances of:
$Property LIKE $Parameter
to
$Property LIKE ‘%$Value%’
This seems to be working now, column filtering. Not sure if that’s correct or not? Doc needs updating? Not sure.
But also - great now the filter works, I get 5 rows back (page size 5) from the database of 100,000+ rows, filtered ok - but then when I page to the next page, the query updates and sets the OFFSET/FETCH correctly but it loses the WHERE filter condition! Anyone know how to keep that WHERE condition no matter which page the user clicks to?
Cheers!
Steve.
$SqlFilter = "WHERE "
$SqlParameters = @{}
$Filter = $Context.Filter
foreach ($item in $Filter.Items) {
$Property = $item.columnField
$Value = $item.Value
$Parameter = "Param" + $SqlParameters.Count
if ($item.operatorValue -eq 'contains')
{
$SqlParameters.Add($Parameter, "%$Value%") | Out-Null
}
else
{
$SqlParameters.Add($Parameter, $Value) | Out-Null
}
switch ($item.operatorValue) {
"contains" { $SqlFilter += "$Property LIKE '%$Value%' AND " }
"equals" { $SqlFilter += "$Property = '$Value' AND " }
"isEmpty" { $SqlFilter += "$Property IS NULL " }
"isNotEmpty" { $SqlFilter += "$Property IS NOT NULL " }
}
}
$SQLFilter += " 1 = 1"