Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions DataGridMAUI/Helpers/SfEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Maui.Platform;
#if ANDROID
using Android.Content.Res;
#endif

namespace DataGridMAUI
{
public class SfEntry : Entry
{
public SfEntry()
{
#if ANDROID
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoUnderline", (h, v) =>
{
if (v is Entry)
{
h.PlatformView.BackgroundTintList = ColorStateList.ValueOf(Colors.Transparent.ToPlatform());
}
});
#endif
#if WINDOWS
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoUnderline", (h, v) =>
{
if (v is Entry)
{
h.PlatformView.BorderThickness = new Microsoft.UI.Xaml.Thickness(0);
h.PlatformView.Padding = new Microsoft.UI.Xaml.Thickness(0, 10, 0, 0);
h.PlatformView.Resources["TextControlBorderThemeThicknessFocused"] = new Microsoft.UI.Xaml.Thickness(0);
}
});
#endif
#if MACCATALYST || IOS
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoUnderline", (h, v) =>
{
if (v is Entry)
{
h.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
}
});
#endif
}
}
}
30 changes: 23 additions & 7 deletions DataGridMAUI/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,29 @@
</editors:SfComboBox.ItemTemplate>
</editors:SfComboBox>

<SearchBar x:Name="filterText"
BackgroundColor="Transparent"
Text="{Binding FilterText}"
WidthRequest="250"
HorizontalOptions="{OnPlatform Android='StartAndExpand',WinUI='End',MacCatalyst='End',iOS='FillAndExpand'}"
IsVisible="true">
</SearchBar>
<Border StrokeThickness="1" VerticalOptions="Center"
BackgroundColor="White"
HeightRequest="38"
StrokeShape="RoundRectangle 8">
<Grid ColumnDefinitions="Auto,*"
Margin="0,0,8,0">
<Label Text="&#xe728;"
FontFamily="MauiSampleFontIcon"
VerticalOptions="Center"
HorizontalOptions="Center"
FontSize="16"
Margin="10,0,12,0" />
<local:SfEntry x:Name="filterText"
Text="{Binding FilterText}"
Grid.Column="1"
BackgroundColor="Transparent"
HorizontalOptions="{OnPlatform Android='StartAndExpand',WinUI='End',MacCatalyst='End',iOS='FillAndExpand'}"
VerticalTextAlignment="{OnPlatform Default=Start, MacCatalyst=Center, iOS=Center}"
FontFamily="Roboto-Regular"
FontSize="16"
ClearButtonVisibility="Never" />
</Grid>
</Border>

</HorizontalStackLayout>
</DataTemplate>
Expand Down
46 changes: 38 additions & 8 deletions DataGridMAUI/ViewModel/GradeSheetViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ private void PopuplateColumnNames()
GridColumnsForGroup.AddRange(GridColumns);
GridColumnsForSort.AddRange(GridColumns);
GridColumns.RemoveAt(0);
GridColumnsForFilter.Remove(GridColumnsForFilter.FirstOrDefault(o => o.Name == "StudentID"));
SelectedColumn = GridColumnsForFilter.FirstOrDefault();
SelectedGroupColumn = GridColumnsForGroup.FirstOrDefault();
SelectedSortColumn = GridColumnsForSort.FirstOrDefault();
Expand Down Expand Up @@ -439,14 +440,24 @@ private void ExecuteClearSorts()
{
if (SortColumnDescriptions == null)
return;
SortColumnDescriptions.Clear();
SortColumnDescriptions.Clear();

SelectedSortColumn = null;

Application.Current?.Dispatcher.Dispatch(() =>
{
IsOpenForSortColumns = false;
});
}

private void ExecuteAddSorting()
{
ExecuteClearSorts();
var sortColumnDescription = new SortColumnDescription() { ColumnName = this.SelectedSortColumn.Name, SortDirection = IsOnState ? ListSortDirection.Ascending : ListSortDirection.Descending };
SortColumnDescriptions.Add(sortColumnDescription);
if (SelectedSortColumn != null)
{
SortColumnDescriptions.Clear();
var sortColumnDescription = new SortColumnDescription() { ColumnName = this.SelectedSortColumn.Name, SortDirection = IsOnState ? ListSortDirection.Ascending : ListSortDirection.Descending };
SortColumnDescriptions.Add(sortColumnDescription);
}
}

// Grouping
Expand All @@ -458,14 +469,24 @@ private void ExecuteClearGroups()
{
if (GroupColumnDescriptions == null)
return;
GroupColumnDescriptions.Clear();
GroupColumnDescriptions.Clear();

SelectedGroupColumn = null;

Application.Current?.Dispatcher.Dispatch(() =>
{
IsOpenForGroupColumns = false;
});
}

private void ExecuteAddGrouping()
{
ExecuteClearGroups();
var groupColumnDescription = new GroupColumnDescription() { ColumnName = this.SelectedGroupColumn.Name };
GroupColumnDescriptions.Add(groupColumnDescription);
if (SelectedGroupColumn != null)
{
GroupColumnDescriptions.Clear();
var groupColumnDescription = new GroupColumnDescription() { ColumnName = this.SelectedGroupColumn.Name };
GroupColumnDescriptions.Add(groupColumnDescription);
}
}

// Show/Hide columns
Expand Down Expand Up @@ -507,7 +528,13 @@ private void ExecuteShowAllColumns()
// Filtering
private void ExecuteClearFilter()
{
SelectedCondition = string.Empty;
SelectedColumn = null;
FilterText = string.Empty;
Application.Current?.Dispatcher.Dispatch(() =>
{
IsOpenForFilterColumns = false;
});
}

private void ExecuteFilterColumns()
Expand All @@ -522,6 +549,9 @@ private void ExecuteFilterColumns()
/// <returns>true or false value</returns>
public bool FilerRecords(object o)
{
if (SelectedColumn == null && string.IsNullOrEmpty(this.SelectedCondition))
return true;

double res;
bool checkNumeric = double.TryParse(this.FilterText, out res);
var item = o as Grade;
Expand Down