-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathObjectArray.razor
More file actions
69 lines (66 loc) · 1.68 KB
/
Copy pathObjectArray.razor
File metadata and controls
69 lines (66 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@using UISupportGeneric.UI
@{
var index = 0;
}
@if (Array == null)
{
return;
}
<div class="text-primary">@Array.Label</div>
<div class="text-secondary">@Array.Description</div>
@if (Array.IsSelector)
{
<select @oninput=OnSelect>
<option hidden selected value="-1">...</option>
@foreach (var record in Array.Records)
{
@if (record != null)
{
<option value="@index" style="white-space: pre-wrap">@string.Join(',',record)</option>
}
index++;
}
</select>
}
else
{
<table class="table">
<thead>
<tr>
@foreach (var fieldName in Array.Titles)
{
<th>@fieldName</th>
}
</tr>
</thead>
<tbody>
@foreach (var record in Array.Records)
{
<tr>
@if (record != null)
{
@foreach (var field in record)
{
<td style="white-space: pre-wrap">@field</td>
}
}
</tr>
}
</tbody>
</table>
}
@code {
// Used to update the container component
[Parameter, EditorRequired]
public Action? RefreshContainer { get; set; }
// Table data to be displayed
[Parameter, EditorRequired]
public TableUISupport? Array { get; set; }
// Handle selection change event
private void OnSelect(ChangeEventArgs args)
{
if (args.Value != null){
Array?.SetSelected(int.Parse((string)args.Value), RefreshContainer);
}
}
}