Ver Fonte

Fix to filter bug and fix to the filter editor

Kenric Nugteren há 7 meses atrás
pai
commit
051deceead

+ 5 - 6
inabox.wpf/DynamicGrid/Editors/FilterEditor/FilterNode.cs

@@ -245,8 +245,8 @@ public class FilterNode<T> : BaseFilterNode
 
 
     private ValueNode? CreateValueNode(string propertyName, Operator op)
     private ValueNode? CreateValueNode(string propertyName, Operator op)
     {
     {
-        var property = CoreUtils.GetProperty(typeof(T), propertyName);
-        return CreateValueNode(property.PropertyType, op);
+        var property = DatabaseSchema.Property(typeof(T), propertyName);
+        return property is not null ? CreateValueNode(property.PropertyType, op) : null;
     }
     }
 
 
     [MemberNotNull(nameof(Value))]
     [MemberNotNull(nameof(Value))]
@@ -262,11 +262,10 @@ public class FilterNode<T> : BaseFilterNode
     private ConstantNode? CreateConstantNode(string? propertyName, Operator op, FilterConstant? constantvalue)
     private ConstantNode? CreateConstantNode(string? propertyName, Operator op, FilterConstant? constantvalue)
     {
     {
         var values = new List<KeyValuePair<string, FilterConstant?>>();
         var values = new List<KeyValuePair<string, FilterConstant?>>();
-        if (!string.IsNullOrWhiteSpace(propertyName))
+        if (!string.IsNullOrWhiteSpace(propertyName) && DatabaseSchema.Property(typeof(T), propertyName) is IProperty property)
         {
         {
-            var property = CoreUtils.GetProperty(typeof(T), propertyName);
-            var constants = FilterConstants.Constants(property.PropertyType, op, property.GetCustomAttribute<AggregateAttribute>() != null);
-            if (constants.Any())
+            var constants = FilterConstants.Constants(property.PropertyType, op, property.HasAttribute<AggregateAttribute>());
+            if (constants.Length != 0)
             {
             {
                 values.Add(new KeyValuePair<string, FilterConstant?>("", null));
                 values.Add(new KeyValuePair<string, FilterConstant?>("", null));
                 foreach (var constant in constants)
                 foreach (var constant in constants)

+ 2 - 4
inabox.wpf/DynamicGrid/UIComponent/DynamicGridGridUIComponent.cs

@@ -271,10 +271,8 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
         var table = DataGridItems;
         var table = DataGridItems;
         if(table is null) return;
         if(table is null) return;
 
 
-        var dataRows = rows.Where(x => x.Index > -1).Select(row =>
-        {
-            return table.Rows[row.Index];
-        });
+
+        var dataRows = rows.Select(x => _rowMap.FirstOrDefault(y => x == y.Value).Key);
         if (!Parent.Options.MultiSelect)
         if (!Parent.Options.MultiSelect)
         {
         {
             dataRows = dataRows.Take(1);
             dataRows = dataRows.Take(1);