UDTable is not working

@adam

The UDTable in v3 is not working for my data I gathered from an custom API using my own PSModule.
The table examples from the hosted doc are working fine but I cannot figure out what I am doing wrong as the data are just strings (ID, Name, Description).
The table is displayed but all rows are empty.

$Columns = @(
                New-UDTableColumn -Property ID -Title ID -Render { 
                    $Item = ConvertFrom-Json $Body -Depth 10
                    New-UDLink -Url "/object/datawarehouse/objecttype/$($Item.ID)"
                }
                New-UDTableColumn -Property Name -Title Name 
                New-UDTableColumn -Property Description -Title Description
            )

            $Table = New-UDTable -Data @(Get-ADWDWObjectType | Select ID, Name, Description) -Columns $Columns
            ConvertTo-Json $Table
{
    "loadData":  null,
    "sort":  false,
    "id":  "5a6ac42b-042f-4e7e-a34f-b14e3e9b265f",
    "type":  "mu-table",
    "data":  [
                 {
                     "ID":  "162c27f4-7ad1-4a6c-b62c-20090151dcc7",
                     "Name":  "AttributeTesting",
                     "Description":  null
                 },
                 {
                     "ID":  "1c229a64-d499-4d91-9102-829412efb6b0",
                     "Name":  "test",
                     "Description":  "testing"
                 },
                 {
                     "ID":  "52103d0b-3144-4fe3-aa94-e3f986926e7c",
                     "Name":  "Auto",
                     "Description":  null
                 },
                 {
                     "ID":  "72ae0e64-c35c-4a0a-aad1-39e056c51d48",
                     "Name":  "Person",
                     "Description":  null
                 },
                 {
                     "ID":  "9a166c5b-0ddf-4759-84b0-b7c15c4d59bd",
                     "Name":  "Person2",
                     "Description":  null
                 }
             ],
    "columns":  [
                    {
                        "id":  "d357340c-e11a-496a-af51-4138971a01f4",
                        "render":  "d357340c-e11a-496a-af51-4138971a01f4",
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "id",
                        "title":  "ID"
                    },
                    {
                        "id":  "9c589f65-7239-42be-b8a3-e72cfc11fdab",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "name",
                        "title":  "Name"
                    },
                    {
                        "id":  "c51b1c96-2544-45d4-a9b1-33318a58c02c",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "description",
                        "title":  "Description"
                    }
                ],
    "search":  false,
    "export":  false,
    "isPlugin":  true,
    "filter":  false,
    "title":  "",
    "assetId":  "index.2852b6957e0dcf5ad8c2.bundle.js"
}

The raw data looks like this:

ConvertTo-Json (Get-ADWDWObjectType) -Depth 10
[
    {
        "Name":  "AttributeTesting",
        "Description":  null,
        "ID":  "162c27f4-7ad1-4a6c-b62c-20090151dcc7"
    },
    {
        "Name":  "test",
        "Description":  "testing",
        "ID":  "1c229a64-d499-4d91-9102-829412efb6b0"
    },
    {
        "Name":  "Auto",
        "Description":  null,
        "ID":  "52103d0b-3144-4fe3-aa94-e3f986926e7c"
    },
    {
        "Name":  "Person",
        "Description":  null,
        "ID":  "72ae0e64-c35c-4a0a-aad1-39e056c51d48"
    },
    {
        "Name":  "Person2",
        "Description":  null,
        "ID":  "9a166c5b-0ddf-4759-84b0-b7c15c4d59bd"
    }
]

Hmm. Looks fine. The only issue I’m seeing is that the field names in the columns are lower case and the property names in your data are capitalized. ID vs id. I just checked and there is code in the UDTable JavaScript to account for this but maybe it isn’t working. I will come up with a test case to ensure that we are validating case insensitivity.

I thought about this but it is the same for the working examples from your hosted doc:

$Data = @(
    @{Dessert = 'Frozen yoghurt'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
    @{Dessert = 'Gingerbread'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
) 

New-UDTable -Data $Data
{
    "loadData":  null,
    "sort":  false,
    "id":  "7de55514-474a-4c3b-a127-0038d717cb2e",
    "type":  "mu-table",
    "data":  [
                 {
                     "Calories":  159,
                     "Dessert":  "Frozen yoghurt",
                     "Carbs":  24,
                     "Protein":  4,
                     "Fat":  6
                 },
                 {
                     "Calories":  159,
                     "Dessert":  "Ice cream sandwich",
                     "Carbs":  24,
                     "Protein":  4,
                     "Fat":  6
                 },
                 {
                     "Calories":  159,
                     "Dessert":  "Eclair",
                     "Carbs":  24,
                     "Protein":  4,
                     "Fat":  6
                 },
                 {
                     "Calories":  159,
                     "Dessert":  "Cupcake",
                     "Carbs":  24,
                     "Protein":  4,
                     "Fat":  6
                 },
                 {
                     "Calories":  159,
                     "Dessert":  "Gingerbread",
                     "Carbs":  24,
                     "Protein":  4,
                     "Fat":  6
                 }
             ],
    "columns":  [
                    {
                        "id":  "ef2f43ba-72b7-4928-befd-646e5d9bb442",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "calories",
                        "title":  "Calories"
                    },
                    {
                        "id":  "e0c47959-f0a4-41f8-8a58-702bd70c1333",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "dessert",
                        "title":  "Dessert"
                    },
                    {
                        "id":  "cb88656b-7eda-4f6f-bdda-5b3bedac694e",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "carbs",
                        "title":  "Carbs"
                    },
                    {
                        "id":  "8a9cffd6-4a84-4813-95b1-91f3aea6d411",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "protein",
                        "title":  "Protein"
                    },
                    {
                        "id":  "2894bd7d-5b76-4264-8ec5-c4061b6ebab7",
                        "render":  null,
                        "filter":  true,
                        "sort":  true,
                        "search":  true,
                        "field":  "fat",
                        "title":  "Fat"
                    }
                ],
    "search":  false,
    "export":  false,
    "isPlugin":  true,
    "filter":  false,
    "title":  "",
    "assetId":  "index.2852b6957e0dcf5ad8c2.bundle.js"
}

@adam

I skipped my custom function by mockup the data in a json but nor even this is working for me:

$Data = ConvertFrom-Json '[{"Name":"AttributeTesting","Description":null,"ID":"162c27f4-7ad1-4a6c-b62c-20090151dcc7"},{"Name":"test","Description":"testing","ID":"1c229a64-d499-4d91-9102-829412efb6b0"},{"Name":"Auto","Description":null,"ID":"52103d0b-3144-4fe3-aa94-e3f986926e7c"},{"Name":"Person","Description":null,"ID":"72ae0e64-c35c-4a0a-aad1-39e056c51d48"},{"Name":"Person2","Description":null,"ID":"9a166c5b-0ddf-4759-84b0-b7c15c4d59bd"}]'

New-UDTable -Data $Data

PS: if a column Property is defined multiple times the page gets blank - this should be possible as I can imagine that this is required some times.

In this example the page gets blank and I dont see a reason for defining the mandatory -Property

$Columns = @(
        
        New-UDTableColumn -Property ID -Title Link -Render { 
            $Item = ConvertFrom-Json $Body -Depth 10
            New-UDLink -Url "/object/datawarehouse/objecttype/$($Item.ID)"
        }
        New-UDTableColumn -Property ID -Title ID
        New-UDTableColumn -Property Name -Title Name 
        New-UDTableColumn -Property Description -Title Description
    )

@adam

Should I open issues for all 3 problems?

  • data not displayed
  • custom error message if the Titel is defined multiple times
  • Property should not be mendatory

Very strange!

Another reason that a page get blanked (broken) is to use the -Depth parameter for a custom column.

New-UDTableColumn -Property ID -Title Link -Render { 
            $Item = ConvertFrom-Json $Body -Depth 10
            New-UDLink -Text 'ID' -Url "/object/objecttype/$($Item.ID)"
}

After removing the -Depth 10 its not broken but the rendering (get the item data in $Item) still not work but I think because of the root cause referred in this thread at the beginning “data is not loaded”.

I have an issue for the page being blank: https://github.com/ironmansoftware/universal-dashboard/issues/1556 - This actually happens with multiple components and I need to fix it.

  • Property should not be mandatory - Agreed. This could use an issue.

I’ll have to figure out what’s going on with the data not displaying. I haven’t had time to try your examples but will try to get to that today or tomorrow. It’s strange because the doc example works and I can tell from looking at the code what’s wrong with it.

1 Like

The problem with your example is that it’s generating PSCustomObject’s via ConvertFrom-Json. The examples in the docs are using Hashtables. UD wasn’t serializing the PSCustomObjects correctly. I have a PR in for that and will get it in tonight’s build.

1 Like

Great that you have fixed that one… will try it tomorrow … :slight_smile: