Skip to content

Commit c6023ba

Browse files
committed
Update validation example
1 parent 4c18cf9 commit c6023ba

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

listview/ValidationExamples/ValidationExamples/Pages/AsyncMethods.razor

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@page "/async"
22

3-
<div class="alert alert-info">This example adds a dummy delay in the update/create operations to simulate an actual remote service (you can add your own, and remove that code). The addition compared to the basic example is the <code>isEditing</code> flag that determines whether to rehydrate the edit context when the delay in the EventCallback re-renders the listview and the templates. This lets you prevent re-initializing that context upon/after completing the data operation.</div>
3+
<div class="alert alert-info">This example adds a dummy delay in the update/create operations to simulate an actual remote service (you can add your own, and remove that code).</div>
44

55
@using System.ComponentModel.DataAnnotations
66

@@ -51,23 +51,16 @@
5151
@code{
5252
Employee currEditItem { get; set; }
5353
EditContext currEditContext { get; set; }
54-
bool isEditing { get; set; }
5554

5655
void EditHandler()
5756
{
58-
isEditing = true;
5957
CleanUpValidation();
6058
}
6159

6260
async Task CreateHandler(ListViewCommandEventArgs e)
6361
{
6462
Employee insertedItem = e.Item as Employee;
6563

66-
67-
// lower the flag so we don't rehydrate the edit context - the EventCallback will re-render the ListView (including its templates) after it completes
68-
// you can flip it back to true as needed (e.g., if validation fails, to rehydrate the validation logic)
69-
isEditing = false;
70-
7164
// simulate a delay - be that server data operation, or server validation
7265
await Task.Delay(400);
7366

@@ -76,7 +69,6 @@
7669
{
7770
// prevent the listview from going back in view mode
7871
e.IsCancelled = true;
79-
isEditing = true;
8072
return;
8173
}
8274

@@ -105,10 +97,6 @@
10597
{
10698
Employee updatedItem = e.Item as Employee;
10799

108-
// lower the flag so we don't rehydrate the edit context - the EventCallback will re-render the ListView (including its templates) after it completes
109-
// you can flip it back to true as needed (e.g., if validation fails, to rehydrate the validation logic)
110-
isEditing = false;
111-
112100
// simulate a delay - be that server data operation, or server validation
113101
await Task.Delay(400);
114102

@@ -117,7 +105,6 @@
117105
{
118106
// prevent the listview from going back in view mode
119107
e.IsCancelled = true;
120-
isEditing = true;
121108
return;
122109
}
123110

@@ -138,7 +125,6 @@
138125

139126
void CancelHandler(ListViewCommandEventArgs e)
140127
{
141-
isEditing = false;
142128
CleanUpValidation();
143129
}
144130

0 commit comments

Comments
 (0)