You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: listview/ValidationExamples/ValidationExamples/Pages/AsyncMethods.razor
+1-15
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
@page "/async"
2
2
3
-
<divclass="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
+
<divclass="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>
4
4
5
5
@usingSystem.ComponentModel.DataAnnotations
6
6
@@ -51,23 +51,16 @@
51
51
@code{
52
52
EmployeecurrEditItem{get; set; }
53
53
EditContextcurrEditContext{get; set; }
54
-
boolisEditing{get; set; }
55
54
56
55
voidEditHandler()
57
56
{
58
-
isEditing=true;
59
57
CleanUpValidation();
60
58
}
61
59
62
60
asyncTaskCreateHandler(ListViewCommandEventArgse)
63
61
{
64
62
EmployeeinsertedItem=e.ItemasEmployee;
65
63
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
-
71
64
// simulate a delay - be that server data operation, or server validation
72
65
awaitTask.Delay(400);
73
66
@@ -76,7 +69,6 @@
76
69
{
77
70
// prevent the listview from going back in view mode
78
71
e.IsCancelled=true;
79
-
isEditing=true;
80
72
return;
81
73
}
82
74
@@ -105,10 +97,6 @@
105
97
{
106
98
EmployeeupdatedItem=e.ItemasEmployee;
107
99
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
-
112
100
// simulate a delay - be that server data operation, or server validation
113
101
awaitTask.Delay(400);
114
102
@@ -117,7 +105,6 @@
117
105
{
118
106
// prevent the listview from going back in view mode
0 commit comments