UDGrid Questions and one issue

So, I’m creating a UDGrid and I am running into a couple of issues…

Here is the creation Code:

New-UDGrid -Id 'blitzresults' - 
Headers @('Priority', 'Findings Group', 'Finding', 'Database Name', 'Details', 'Info URL') - 
Properties @('Priority', 'FindingsGroup', 'Finding', 'DatabaseName', 'Details', 'URL') -Endpoint {
                        $Cache:ReportData.HCResults | ForEach-Object {  
                                Priority = $_.Priority
                                FindingsGroup = $_.FindingsGroup
                                Finding = $_.Finding
                                DatabaseName = $_.DatabaseName
                                Details = $_.Details
                                InfoURL = (New-UDLink -Text 'More Info' -Url $_.URL)
                        } | Out-UDGridData  
                    } -DefaultSortColumn '0' -

And here is how the Grid looks:

  1. I cannot get the Grid to Auto Sort. Is there some ‘trick’ that I am missing?
  2. The URL is not showing.
    I have inspected the Object, and the $_.url value does contain a URL, as a [string]
    Not sure what I should do differently here…

Bonus Points :innocent:

  1. Is there any way to adjust the font size in the Grid?
  2. Is there any way to allow the ‘user’ to choose to display more items per page, or do I have to manually create some form of UDInput function to get that functionality?

Thank you, in advance, for your assistance.

You property hashtable say ‘url’ and not “infourl” as you data set.
The sort, u need to set it as the header name, so change from ‘0’ to ‘priority’

For the user change on page size, you need to make a input and have the user define it there and then reload the page with the grid using the session variable or what you store it in on the pagesize parameter.

1 Like

Have a look here:- https://poshud.com/New-UDGrid
then at the bottom of the page is the parameters and you will find:-
DefaultSortColumn Specifies the column index of the default sort column. This index begins with zero.
DefaultSortDescending Specifies whether to sort descending or ascending by default. SwitchParameter named
As for sorting the font you need to look here:- https://docs.universaldashboard.io/look-and-feel/themes#available-properties and you will see how you could adjust this in the CSS.

1 Like


Changing the Sort Column from ‘0’ to ‘Priority’ worked. :smiley:

I am still not able to get the URL to show in the Grid…

The $_.URL does contain a valid URL, but perhaps I need to ‘transform’ the value, in some way?

$Cache:ReportData.HCResults is a DataRow, so perhaps that is affecting the encoding of the URL string in some way?

When I look at the object properties, URL is showing as a string…so that doesn’t seem to be the case.

PS UD:\>  $cache:reportdata.hcresults | gm

   TypeName: System.Data.DataRow

Name              MemberType            Definition                                                                      
----              ----------            ----------                                                                      
AcceptChanges     Method                void AcceptChanges()                                                            
BeginEdit         Method                void BeginEdit()                                                                
CancelEdit        Method                void CancelEdit()                                                               
ClearErrors       Method                void ClearErrors()                                                              
Delete            Method                void Delete()                                                                   
EndEdit           Method                void EndEdit()                                                                  
Equals            Method                bool Equals(System.Object obj)                                                  
GetChildRows      Method                System.Data.DataRow[] GetChildRows(string relationName), System.Data.DataRow[...
GetColumnError    Method                string GetColumnError(int columnIndex), string GetColumnError(string columnNa...
GetColumnsInError Method                System.Data.DataColumn[] GetColumnsInError()                                    
GetHashCode       Method                int GetHashCode()                                                               
GetParentRow      Method                System.Data.DataRow GetParentRow(string relationName), System.Data.DataRow Ge...
GetParentRows     Method                System.Data.DataRow[] GetParentRows(string relationName), System.Data.DataRow...
GetType           Method                type GetType()                                                                  
HasVersion        Method                bool HasVersion(System.Data.DataRowVersion version)                             
IsNull            Method                bool IsNull(int columnIndex), bool IsNull(string columnName), bool IsNull(Sys...
RejectChanges     Method                void RejectChanges()                                                            
SetAdded          Method                void SetAdded()                                                                 
SetColumnError    Method                void SetColumnError(int columnIndex, string error), void SetColumnError(strin...
SetModified       Method                void SetModified()                                                              
SetParentRow      Method                void SetParentRow(System.Data.DataRow parentRow), void SetParentRow(System.Da...
ToString          Method                string ToString()                                                               
Item              ParameterizedProperty System.Object Item(int columnIndex) {get;set;}, System.Object Item(string col...
CheckDate         Property              System.DateTimeOffset CheckDate {get;set;}                                      
CheckID           Property              int CheckID {get;set;}                                                          
DatabaseName      Property              string DatabaseName {get;set;}                                                  
Details           Property              string Details {get;set;}                                                       
Finding           Property              string Finding {get;set;}                                                       
FindingsGroup     Property              string FindingsGroup {get;set;}                                                 
ID                Property              int ID {get;set;}                                                               
Priority          Property              byte Priority {get;set;}                                                        
QueryPlan         Property              string QueryPlan {get;set;}                                                     
QueryPlanFiltered Property              string QueryPlanFiltered {get;set;}                                             
ServerName        Property              string ServerName {get;set;}                                                    
URL               Property              string URL {get;set;}

But that is not the object you send to the grid. It’s the pscustomobject, and the url property in that have you called ‘InfoURL’ so you need to use that name

1 Like

Yeah, I saw that, and did make the change. The object uses URL and the Header are URL now.

Here is the ‘updated’ code:

New-UDGrid -Id 'blitzresults' -Headers @('Priority', 'Findings Group', 'Finding', 'Database Name', 'Details', 'URL') -Properties @('Priority', 'FindingsGroup', 'Finding', 'DatabaseName', 'Details', 'URL') -Endpoint {
                        $Cache:ReportData.HCResults | ForEach-Object {  
                                Priority = $_.Priority
                                FindingsGroup = $_.FindingsGroup
                                Finding = $_.Finding
                                DatabaseName = $_.DatabaseName
                                Details = $_.Details
                                InfoURL = (New-UDLink -Text 'More Info' -Url $_.URL)
                        } | Out-UDGridData  
                    } -DefaultSortColumn 'Priority'

It is still not showing the URL in the grid…

Yeah you have still not changed the -properties to infourl. You still have it to url

1 Like

Wow, totally missed that one. Thanks.

Only told you 3 times :wink:

Yeah, I tend to not be able to ‘see the forest, for the trees’ at times :rofl:

Thanks again.