Skip to content

Commit a67f71e

Browse files
Merge pull request #1 from Tamilarasan-Paranthaman/master
How to delete all the rows at runtime in MAUI DataGrid (SfDataGrid)?
2 parents 8a4a8f2 + 907e985 commit a67f71e

38 files changed

+1206
-1
lines changed

MauiApp1.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31611.283
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp1", "MauiApp1\MauiApp1.csproj", "{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
Release-Xml|Any CPU = Release-Xml|Any CPU
13+
EndGlobalSection
14+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
18+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Release|Any CPU.Deploy.0 = Release|Any CPU
21+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
22+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
23+
{E5E9FFEC-D2A9-4FD5-8B72-A6FF99B09F68}.Release-Xml|Any CPU.Deploy.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
30+
EndGlobalSection
31+
EndGlobal

MauiApp1/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiApp1"
5+
x:Class="MauiApp1.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

MauiApp1/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MauiApp1;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}

MauiApp1/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="MauiApp1.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:MauiApp1"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

MauiApp1/AppShell.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace MauiApp1;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}

MauiApp1/MainPage.xaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiApp1"
5+
xmlns:dataGrid="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
6+
x:Class="MauiApp1.MainPage">
7+
<ContentPage.BindingContext>
8+
<local:OrderInfoRepository x:Name="viewModel"/>
9+
</ContentPage.BindingContext>
10+
<Grid>
11+
<Grid.RowDefinitions>
12+
<RowDefinition Height="Auto"/>
13+
<RowDefinition Height="*"/>
14+
</Grid.RowDefinitions>
15+
<Button Text="Delete All the Rows" Clicked="Delete_All_Button_Clicked" Grid.Row="0" Margin="0,10,0,10"></Button>
16+
<dataGrid:SfDataGrid x:Name="dataGrid"
17+
ItemsSource="{Binding OrderInfoCollection}"
18+
ColumnWidthMode="Auto"
19+
Grid.Row="1"
20+
>
21+
</dataGrid:SfDataGrid>
22+
</Grid>
23+
24+
</ContentPage>

MauiApp1/MainPage.xaml.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+

2+
using Syncfusion.Maui.DataGrid;
3+
using Syncfusion.Maui.Inputs;
4+
5+
namespace MauiApp1
6+
{
7+
8+
public partial class MainPage : ContentPage
9+
{
10+
11+
public MainPage()
12+
{
13+
InitializeComponent();
14+
15+
}
16+
17+
private void Delete_All_Button_Clicked(object sender, EventArgs e)
18+
{
19+
if (viewModel.OrderInfoCollection != null)
20+
{
21+
viewModel.OrderInfoCollection.Clear();
22+
}
23+
24+
}
25+
}
26+
}
27+
28+
29+

MauiApp1/MauiApp1.csproj

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>MauiApp1</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>MauiApp1</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.mauiapp1</ApplicationId>
19+
<ApplicationIdGuid>07f601bb-4226-41ec-9f54-0051f090ead8</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
44+
<!-- Custom Fonts -->
45+
<MauiFont Include="Resources\Fonts\*" />
46+
47+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="Syncfusion.Maui.DataGrid" Version="23.1.43" />
53+
</ItemGroup>
54+
55+
</Project>

MauiApp1/MauiProgram.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace MauiApp1;
2+
using Syncfusion.Maui.Core.Hosting;
3+
4+
public static class MauiProgram
5+
{
6+
public static MauiApp CreateMauiApp()
7+
{
8+
var builder = MauiApp.CreateBuilder();
9+
builder
10+
.UseMauiApp<App>()
11+
.ConfigureFonts(fonts =>
12+
{
13+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
14+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
15+
});
16+
17+
builder.ConfigureSyncfusionCore();
18+
return builder.Build();
19+
}
20+
}

MauiApp1/Model/OrderInfo.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace MauiApp1
8+
{
9+
public class OrderInfo
10+
{
11+
private int orderID;
12+
private string customerID;
13+
private string customer;
14+
private string shipCity;
15+
private string shipCountry;
16+
private double price;
17+
18+
public int OrderID
19+
{
20+
get { return orderID; }
21+
set { this.orderID = value; }
22+
}
23+
24+
public string CustomerID
25+
{
26+
get { return customerID; }
27+
set { this.customerID = value; }
28+
}
29+
30+
public string ShipCountry
31+
{
32+
get { return shipCountry; }
33+
set { this.shipCountry = value; }
34+
}
35+
36+
public string Customer
37+
{
38+
get { return this.customer; }
39+
set { this.customer = value; }
40+
}
41+
42+
public string ShipCity
43+
{
44+
get { return shipCity; }
45+
set { this.shipCity = value; }
46+
}
47+
48+
public double Price
49+
{
50+
get { return price; }
51+
set { this.price = value; }
52+
}
53+
54+
public OrderInfo(int orderId, string customer, string country, string customerId, string shipCity, double price)
55+
{
56+
this.OrderID = orderId;
57+
this.Customer = customer;
58+
this.ShipCountry = country;
59+
this.CustomerID = customerId;
60+
this.ShipCity = shipCity;
61+
this.Price = price;
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)