Ejemplo n.º 1
0
        protected async void SortData(MatSortChangedEvent sort)
        {
            sortBy  = sort.SortId;
            sortDir = sort.Direction == MatSortDirection.Asc ? "asc" : "desc";

            await getList();
        }
Ejemplo n.º 2
0
 protected async Task SortData(MatSortChangedEvent sort)
 {
     if (!(sort == null || sort.Direction == MatSortDirection.None || string.IsNullOrEmpty(sort.SortId)))
     {
         Sort = new SortChangeEvent()
         {
             SortId = sort.SortId, Direction = (SortDirection)Enum.Parse(typeof(SortDirection), sort.Direction.ToString())
         };
         GridConfig.ItemList = await GridConfig.GetPageAsync(Sort, GridSearch);
     }
 }
Ejemplo n.º 3
0
        private static IQueryable <ReplayInfo>?ApplyFilter(IQueryable <ReplayInfo> replays, MatSortChangedEvent e)
        {
            if (e.Direction == MatSortDirection.None)
            {
                return(replays);
            }

            var entityType   = typeof(ReplayInfo);
            var propertyName = nameof(ReplayInfo.DateTime);

            var propertyInfo = entityType.GetProperty(propertyName);

            if (propertyInfo?.DeclaringType != entityType)
            {
                propertyInfo = propertyInfo?.DeclaringType?.GetProperty(propertyName);
            }

            if (propertyInfo is null)
            {
                return(replays);
            }

            var arg      = Expression.Parameter(entityType, "r");
            var property = Expression.MakeMemberAccess(arg, propertyInfo);
            var selector = Expression.Lambda(property, arg);

            string method        = e.Direction == MatSortDirection.Asc ? "OrderByDescending" : "OrderBy";
            var    genericMethod = typeof(Queryable).GetMethods()
                                   .Where(m => m.Name == method && m.IsGenericMethodDefinition && m.GetParameters().Length == 2)
                                   .Single()
                                   .MakeGenericMethod(entityType, propertyInfo.PropertyType);

            if (genericMethod != null)
            {
                return((IOrderedQueryable <ReplayInfo>?)genericMethod?.Invoke(genericMethod, new object[] { replays, selector }));
            }

            return(null);
        }
Ejemplo n.º 4
0
 public async void OnFilter(MatSortChangedEvent e)
 {
     await FilterChanged.InvokeAsync(replays => ApplyFilter(replays, e));
 }