From 9bc6adb99f1d28199d8363fc60945ec00e44cb99 Mon Sep 17 00:00:00 2001 From: tesar-tech Date: Fri, 13 Dec 2024 11:38:02 +0100 Subject: [PATCH 1/3] Datagrid - prevents submitting form on Enter in Filter if SubmitFormOnEnter is false. closes #5790 --- Source/Extensions/Blazorise.DataGrid/DataGrid.razor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor index 784834d4cc..a5ebfa48f4 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor @@ -12,7 +12,8 @@ }
- @if ( IsCellEdit && ( CommandColumn is null || !CommandColumn.SaveCommandAllowed ) ) + @if ( (IsCellEdit && (CommandColumn is null || !CommandColumn.SaveCommandAllowed)) + || (Filterable && !SubmitFormOnEnter) ) { //Disable the default form behaviour where pressing enter submits the form and posts the page which is not expected in typical SPA fashion. From adb1a2e4452aea1eb407ea140f296ceeeac16ba1 Mon Sep 17 00:00:00 2001 From: tesar-tech Date: Fri, 13 Dec 2024 17:23:26 +0100 Subject: [PATCH 2/3] Creates PreventDefaultSubmitBehavior private property --- Source/Extensions/Blazorise.DataGrid/DataGrid.razor | 4 +--- Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor index a5ebfa48f4..e8efe20824 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor @@ -12,10 +12,8 @@ } - @if ( (IsCellEdit && (CommandColumn is null || !CommandColumn.SaveCommandAllowed)) - || (Filterable && !SubmitFormOnEnter) ) + @if ( PreventDefaultSubmitBehavior ) { - //Disable the default form behaviour where pressing enter submits the form and posts the page which is not expected in typical SPA fashion. } diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs index b34ddec160..7969704c02 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs @@ -155,7 +155,14 @@ public partial class DataGrid : BaseDataGridComponent /// Tracks the current batch edit changes if is active. /// private List> batchChanges; - + + /// + /// Disable the default form behaviour where pressing enter submits the form and posts the page which is not expected in typical SPA fashion. + /// + private bool PreventDefaultSubmitBehavior => + (IsCellEdit && (CommandColumn is null || !CommandColumn.SaveCommandAllowed)) + || (Filterable && !SubmitFormOnEnter); //prevents submits on Enter within Filter input + #endregion #region Constructors From b8a8486d133f274f65a857c4eb7779d9b1b0a6c6 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Fri, 13 Dec 2024 17:52:57 +0100 Subject: [PATCH 3/3] Formating --- .../Extensions/Blazorise.DataGrid/DataGrid.razor | 1 - .../Blazorise.DataGrid/DataGrid.razor.cs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor index e8efe20824..7f8bb013c1 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor @@ -11,7 +11,6 @@ @paginationFragment } - @if ( PreventDefaultSubmitBehavior ) { diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs index 7969704c02..704ee6fd83 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs @@ -155,14 +155,7 @@ public partial class DataGrid : BaseDataGridComponent /// Tracks the current batch edit changes if is active. /// private List> batchChanges; - - /// - /// Disable the default form behaviour where pressing enter submits the form and posts the page which is not expected in typical SPA fashion. - /// - private bool PreventDefaultSubmitBehavior => - (IsCellEdit && (CommandColumn is null || !CommandColumn.SaveCommandAllowed)) - || (Filterable && !SubmitFormOnEnter); //prevents submits on Enter within Filter input - + #endregion #region Constructors @@ -3142,6 +3135,13 @@ internal bool MultiSelect /// protected bool PopupVisible => EditMode == DataGridEditMode.Popup && EditState != DataGridEditState.None; + /// + /// Disable the default form behaviour where pressing enter submits the form and posts the page which is not expected in typical SPA fashion. + /// + private bool PreventDefaultSubmitBehavior => + ( IsCellEdit && ( CommandColumn is null || !CommandColumn.SaveCommandAllowed ) ) + || ( Filterable && !SubmitFormOnEnter ); //prevents submits on Enter within Filter input + /// /// Defines the size of popup dialog. ///