diff --git a/src/BootstrapBlazor/Components/Filters/FilterKeyValueAction.cs b/src/BootstrapBlazor/Components/Filters/FilterKeyValueAction.cs
index 6586227bc66..ccae1945a18 100644
--- a/src/BootstrapBlazor/Components/Filters/FilterKeyValueAction.cs
+++ b/src/BootstrapBlazor/Components/Filters/FilterKeyValueAction.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -20,6 +20,7 @@ public class FilterKeyValueAction
///
/// 获得/设置 Filter 项字段值
///
+ [JsonConverter(typeof(ObjectWithTypeConverter))]
public object? FieldValue { get; set; }
///
diff --git a/src/BootstrapBlazor/Converter/JsonQueryPageOptionConverter.cs b/src/BootstrapBlazor/Converter/JsonQueryPageOptionConverter.cs
index d4c9620a95e..9de0c633ee6 100644
--- a/src/BootstrapBlazor/Converter/JsonQueryPageOptionConverter.cs
+++ b/src/BootstrapBlazor/Converter/JsonQueryPageOptionConverter.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -104,80 +104,14 @@ public class JsonQueryPageOptionsConverter : JsonConverter
reader.Read();
ret.IsVirtualScroll = reader.GetBoolean();
}
- else if (propertyName == "searches")
+
+ else if (propertyName == "filterKeyValueAction")
{
reader.Read();
- if (reader.TokenType == JsonTokenType.StartArray)
- {
- while (reader.Read())
- {
- if (reader.TokenType == JsonTokenType.EndArray)
- {
- break;
- }
- var val = JsonSerializer.Deserialize(ref reader, options);
- if (val != null)
- {
- ret.Searches.Add(val);
- }
- }
- }
- }
- else if (propertyName == "customerSearches")
- {
- reader.Read();
- if (reader.TokenType == JsonTokenType.StartArray)
- {
- while (reader.Read())
- {
- if (reader.TokenType == JsonTokenType.EndArray)
- {
- break;
- }
- var val = JsonSerializer.Deserialize(ref reader, options);
- if (val != null)
- {
- ret.CustomerSearches.Add(val);
- }
- }
- }
- }
- else if (propertyName == "advanceSearches")
- {
- reader.Read();
- if (reader.TokenType == JsonTokenType.StartArray)
- {
- while (reader.Read())
- {
- if (reader.TokenType == JsonTokenType.EndArray)
- {
- break;
- }
- var val = JsonSerializer.Deserialize(ref reader, options);
- if (val != null)
- {
- ret.AdvanceSearches.Add(val);
- }
- }
- }
- }
- else if (propertyName == "filters")
- {
- reader.Read();
- if (reader.TokenType == JsonTokenType.StartArray)
+ var val = JsonSerializer.Deserialize(ref reader, options);
+ if (val != null)
{
- while (reader.Read())
- {
- if (reader.TokenType == JsonTokenType.EndArray)
- {
- break;
- }
- var val = JsonSerializer.Deserialize(ref reader, options);
- if (val != null)
- {
- ret.Filters.Add(val);
- }
- }
+ ret.FilterKeyValueAction = val;
}
}
else if (propertyName == "isFirstQuery")
@@ -252,41 +186,12 @@ public override void Write(Utf8JsonWriter writer, QueryPageOptions value, JsonSe
{
writer.WriteBoolean("isVirtualScroll", value.IsVirtualScroll);
}
- if (value.Searches.Count != 0)
- {
- writer.WriteStartArray("searches");
- foreach (var filter in value.Searches)
- {
- writer.WriteRawValue(JsonSerializer.Serialize(filter, options));
- }
- writer.WriteEndArray();
- }
- if (value.CustomerSearches.Count != 0)
- {
- writer.WriteStartArray("customerSearches");
- foreach (var filter in value.CustomerSearches)
- {
- writer.WriteRawValue(JsonSerializer.Serialize(filter, options));
- }
- writer.WriteEndArray();
- }
- if (value.AdvanceSearches.Count != 0)
- {
- writer.WriteStartArray("advanceSearches");
- foreach (var filter in value.AdvanceSearches)
- {
- writer.WriteRawValue(JsonSerializer.Serialize(filter, options));
- }
- writer.WriteEndArray();
- }
- if (value.Filters.Count != 0)
+
+ if (value.Searches.Count != 0||value.CustomerSearches.Count != 0||value.AdvanceSearches.Count != 0|| value.Filters.Count != 0)
{
- writer.WriteStartArray("filters");
- foreach (var filter in value.Filters)
- {
- writer.WriteRawValue(JsonSerializer.Serialize(filter, options));
- }
- writer.WriteEndArray();
+ writer.WritePropertyName("filterKeyValueAction");
+ var filterKeyValueAction = value.ToFilter();
+ writer.WriteRawValue(JsonSerializer.Serialize(filterKeyValueAction, options));
}
if (value.IsFirstQuery)
{
diff --git a/src/BootstrapBlazor/Converter/ObjectWithTypeConverter.cs b/src/BootstrapBlazor/Converter/ObjectWithTypeConverter.cs
new file mode 100644
index 00000000000..4833decaf0f
--- /dev/null
+++ b/src/BootstrapBlazor/Converter/ObjectWithTypeConverter.cs
@@ -0,0 +1,34 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License
+// See the LICENSE file in the project root for more information.
+// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
+
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace BootstrapBlazor.Components;
+
+internal class ObjectWithTypeConverter : JsonConverter