Fresh data in modal grid

Hi all,

I have a main grid which brings back a set of data and adds a ‘Details’ button. When the user clicks the details button, a modal form is shown with a grid with more information. This is working well.

However I have an issue where if the user clicks off the modal form, then clicks details on another record, the more information grid does not get refreshed and still shows the data from the 1st record.

Any ideas? Thanks

Invoke-Sqlcmd2 @SQLticketParams | ForEach-Object {
                                [PSCustomObject]@{
                                    #ID               = $_.ID
                                    SiteCode         = $_.SiteCode
                                    RegistrationCode = $_.RegistrationCode
                                    TransactionDate  = $_.TransactionDate
                                    TransactionNo    = $_.TransactionNo
                                    SequenceCode     = $_.SequenceCode
                                    Resend           = New-UDButton -Text "Details" -onclick {
                                        Show-UDModal -Width '98%' -Content {
                                            New-UDButton -Text "Replay"  -OnClick {
                                                Replay-Weighticket -TransactionNo $_.TransactionNo -TransactionID $_.ID -sitecode $_.SiteCode
                                                Show-UDToast -Message "Replayed $($_.TransactionNo)" -Duration 10000
                                            }
                                            New-UDGrid -id 'auditdetailgrid' -Title "Showing audit details for $($_.TransactionNo)" -AutoRefresh -RefreshInterval 300 -PageSize 50  -Endpoint {
                                                Get-WeighticketAudit -TransactionNo $_.TransactionNo | Out-UDGridData
                                            }
                                            
                                        }

                                    }
                                }
                            } | Out-UDGridData

I had a similar problem and solved it by making the modal persistent and adding a close button. It seemed to force the re-evaluation of the content.

New-UDButton -Text "Details" -OnClick {
	Show-UDModal -Height 100% -Width 90% -Persistent -Content {
		New-UDGrid -title "Details for $($_.id)" etc
	} -FixedFooter -Footer {
		New-UDButton -Text 'Close' -OnClick {
			Hide-UDModal
		}
	}
}

gav

Thanks @OpsEng. I tried updating it to the following, but when going in the second time it just sits with the loading bar :confused:

Invoke-Sqlcmd2 @SQLticketParams | ForEach-Object {
                                [PSCustomObject]@{
                                    #ID               = $_.ID
                                    SiteCode         = $_.SiteCode
                                    RegistrationCode = $_.RegistrationCode
                                    TransactionDate  = $_.TransactionDate
                                    TransactionNo    = $_.TransactionNo
                                    SequenceCode     = $_.SequenceCode
                                    Resend           = New-UDButton -Text "Details" -onclick {
                                        Show-UDModal -Persistent -Width '98%' -Content {
                                            New-UDButton -Text "Replay"  -OnClick {
                                                Replay-Weighticket -TransactionNo $_.TransactionNo -TransactionID $_.ID -sitecode $_.SiteCode
                                                Show-UDToast -Message "Replayed $($_.TransactionNo)" -Duration 10000
                                            }
                                            New-UDButton -Text 'Close' -OnClick {
			                                    Hide-UDModal
		                                    }
                                            New-UDGrid -id 'auditdetailgrid' -Title "Showing audit details for $($_.TransactionNo)" -AutoRefresh -RefreshInterval 300 -PageSize 50  -Endpoint {
                                                Get-WeighticketAudit -TransactionNo $_.TransactionNo | Out-UDGridData
                                            }
                                            
                                        }

                                    }
                                }
                            } | Out-UDGridData