You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.1 KiB
28 lines
1.1 KiB
using System.Linq.Expressions;
|
|
using Connected.Components;
|
|
|
|
namespace Connected
|
|
{
|
|
public static class TableExtensions
|
|
{
|
|
public static IOrderedEnumerable<TSource> OrderByDirection<TSource, TKey>(this IEnumerable<TSource> source, SortDirection direction, Func<TSource, TKey> keySelector)
|
|
{
|
|
if (direction == SortDirection.Descending)
|
|
return source.OrderByDescending(keySelector);
|
|
return source.OrderBy(keySelector);
|
|
}
|
|
|
|
public static IOrderedQueryable<TSource> OrderByDirection<TSource, TKey>(this IQueryable<TSource> source, SortDirection direction, Expression<Func<TSource, TKey>> keySelector)
|
|
{
|
|
if (direction == SortDirection.Descending)
|
|
return source.OrderByDescending(keySelector);
|
|
return source.OrderBy(keySelector);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Disabled the edit button if edit row switching is blocked and the provided item is not being edited
|
|
/// </summary>
|
|
public static bool EditButtonDisabled<T>(this TableContext context, T item) => (context?.Table.IsEditRowSwitchingBlocked ?? false) && context?.Table._editingItem != null && !ReferenceEquals(context?.Table._editingItem, item);
|
|
}
|
|
}
|