New-UDDataGrid or New-UDTable with fully editable fields

Product: PowerShell Universal
Version: 4.2.14

Hello

This my second approach to New-UDDataGrid (or New-UDTable ) with editable fields.
In my first approach i managed to wrote some internal logic to make it work but this time im struggling to get the right idea how to do it

let say i read a bunch of servers and ip addresses that are bounded to those servers

i get table like this

server1 ip1 ip2 ip3 ip4 ip5 ip6
server2 ip1 ip2 ip3 ip4 ip5 ip6
server3 ip1 ip2 ip3 ip4 ip5 ip6
server4 ip1 ip2 ip3 ip4 ip5 ip6

some of the ips might be empty

And i want user to change those IP and then save it and execute changes on the servers.

the best way will of course to use New-UDDataGrid but the way it make it changes (by updating new row and old row property) doesn’t fit to my need very well.
I want to make sure that string that user is typing is an ip address (xxx.xxx.xxx.xxx) and that each values is not larger than 255 (which obvious for ip address)
I have new row and old row where i can see changes but how to get an array index for those changes by comparing those two hashtables (old row and new row)
I have to now exact location where user is making changes (row and column index)
Either i don’t understand how it should be used or this editable feature it is just for show not real scenario cases

I wish that this edit feature would have more easy to use syntax…

Anyway any ideas how to resolve such problem ?

ok that my code that more or less is doing this job

New-UDApp -Title 'PowerShell Universal' -Content {
    $critical_servers = @(
        @{domain = 'EU'; server = 'SERVER1'; ip1 = "192.168.1.10"; ip2 = "192.168.1.11";ip3 = "192.168.1.12";ip4 = ""}
        @{domain = 'EU';server = 'SERVER2'; ip1 = "192.168.1.10"; ip2 = "192.168.1.11";ip3 = "192.168.1.12";ip4 = ""}
        @{domain = 'US';server = 'SERVER3'; ip1 = "192.168.1.10"; ip2 = "192.168.1.11";ip3 = "192.168.1.12";ip4 = "192.168.1.15"}
    )

    $ips = @('ip1','ip2','ip3','ip4')
    $row_count =  ($critical_servers).Length
    $pattern = "^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$"

    New-UDDynamic -id server_table_dynamic -Content {
        New-UDDataGrid -Id 'server_grid' -PageSize 20 -Density compact -LoadRows {
            Out-UDDataGridData -Context $EventData -Data $critical_servers -TotalRows $row_count
        } -Columns @(
            @{ field = "domain";width = 150;}
            @{ field = "server";width = 150;}
            @{ field = "ip1";width = 150 ;editable = $true }
            @{ field = "ip2";width = 150 ;editable = $true }
            @{ field = "ip3";width = 150 ;editable = $true }
            @{ field = "ip4";width = 150 ;editable = $true }
            @{ field = "action";width = 150;render =
                {
                    New-UDIconButton -Icon (New-UDIcon -Icon 'Save' -Solid ) -OnClick {
                    }
                }
            }
        ) -OnSelectionChange {
            $page:selected_rows = $EventData
        } -OnEdit {
            $new_row = $EventData.newRow
            $old_row = $EventData.oldRow
            $row_idnex = $EventData.oldRow.id
            $old_row_server = $old_row.server
            $critical_servers_index = ($critical_servers.server).indexof($old_row_server)
            
            foreach ($ip in $ips)
            {
                $n++
                $new_row_ip = $new_row.$ip
                if (($new_row_ip -match $pattern ) -or (! $new_row_ip))
                {
                    ($critical_servers[$critical_servers_index]).$ip = $new_row.$ip
                }
                else
                {
                    Show-UDToast "$new_row_ip is not valid ip" -Position center -MessageColor red -Duration 3000
                }
            }
            Sync-UDElement -Id 'server_table_dynamic'
        }
    }
}