From c6023ba88d8ee4a6bae8b81243a04d83071f4b92 Mon Sep 17 00:00:00 2001 From: Nansi Yancheva <106161782+NansiYancheva@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:16:23 +0300 Subject: [PATCH] Update validation example --- .../ValidationExamples/Pages/AsyncMethods.razor | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/listview/ValidationExamples/ValidationExamples/Pages/AsyncMethods.razor b/listview/ValidationExamples/ValidationExamples/Pages/AsyncMethods.razor index 30dda84c..195e4399 100644 --- a/listview/ValidationExamples/ValidationExamples/Pages/AsyncMethods.razor +++ b/listview/ValidationExamples/ValidationExamples/Pages/AsyncMethods.razor @@ -1,6 +1,6 @@ @page "/async" -
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 isEditing 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.
+
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).
@using System.ComponentModel.DataAnnotations @@ -51,11 +51,9 @@ @code{ Employee currEditItem { get; set; } EditContext currEditContext { get; set; } - bool isEditing { get; set; } void EditHandler() { - isEditing = true; CleanUpValidation(); } @@ -63,11 +61,6 @@ { Employee insertedItem = e.Item as Employee; - - // lower the flag so we don't rehydrate the edit context - the EventCallback will re-render the ListView (including its templates) after it completes - // you can flip it back to true as needed (e.g., if validation fails, to rehydrate the validation logic) - isEditing = false; - // simulate a delay - be that server data operation, or server validation await Task.Delay(400); @@ -76,7 +69,6 @@ { // prevent the listview from going back in view mode e.IsCancelled = true; - isEditing = true; return; } @@ -105,10 +97,6 @@ { Employee updatedItem = e.Item as Employee; - // lower the flag so we don't rehydrate the edit context - the EventCallback will re-render the ListView (including its templates) after it completes - // you can flip it back to true as needed (e.g., if validation fails, to rehydrate the validation logic) - isEditing = false; - // simulate a delay - be that server data operation, or server validation await Task.Delay(400); @@ -117,7 +105,6 @@ { // prevent the listview from going back in view mode e.IsCancelled = true; - isEditing = true; return; } @@ -138,7 +125,6 @@ void CancelHandler(ListViewCommandEventArgs e) { - isEditing = false; CleanUpValidation(); }