Skip to content

Commit 362fef7

Browse files
Merge pull request #1 from SyncfusionExamples/861290
MAUI-861290-How to perform indirect editing using a template column in the .NET MAUI DataGrid (SfDataGrid)
2 parents 70bb855 + 56ed147 commit 362fef7

40 files changed

Lines changed: 1402 additions & 2 deletions

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
1-
# How-to-perform-indirect-editing-using-a-template-column-in-the-.NET-MAUI-DataGrid-SfDataGrid
2-
This demo shows how to perform indirect editing using a template column in the .NET MAUI DataGrid (SfDataGrid)?
1+
# How to perform indirect editing using a template column in the .NET MAUI DataGrid SfDataGrid
2+
If your need involves indirectly editing the text of `DataGridCell` at runtime, [SfDataGrid](https://www.syncfusion.com/maui-controls/maui-datagrid) facilitates this by enabling the creation of a `TemplateColumn`. You can achieve this by loading an Entry cell into it using the `DataTemplate` property, and the edited values are automatically committed.
3+
4+
Please refer to the following code example for editing the text of a DataGridCell at runtime.
5+
##### xaml:
6+
```XML
7+
<syncfusion:SfDataGrid x:Name="dataGrid"
8+
ItemsSource="{Binding Employees}"
9+
AutoGenerateColumnsMode="None"
10+
DefaultColumnWidth="155">
11+
<syncfusion:SfDataGrid.Columns>
12+
<syncfusion:DataGridTextColumn MappingName="EmployeeID"
13+
HeaderText="Employee ID"/>
14+
<syncfusion:DataGridTemplateColumn MappingName="Name">
15+
<syncfusion:DataGridTemplateColumn.CellTemplate>
16+
<DataTemplate>
17+
<Entry x:Name="label"
18+
Text="{Binding Name}"
19+
TextColor="Black"
20+
HorizontalOptions="FillAndExpand"
21+
VerticalOptions="FillAndExpand" />
22+
</DataTemplate>
23+
</syncfusion:DataGridTemplateColumn.CellTemplate>
24+
</syncfusion:DataGridTemplateColumn>
25+
<syncfusion:DataGridTextColumn MappingName="IDNumber"
26+
HeaderText="ID Number" />
27+
</syncfusion:SfDataGrid.Columns>
28+
</syncfusion:SfDataGrid>
29+
```
30+
31+
32+
[View sample in GitHub](https://github.com/SyncfusionExamples/How-to-perform-indirect-editing-using-a-template-column-in-the-.NET-MAUI-DataGrid-SfDataGrid/tree/master)
33+
34+
Take a moment to explore this [documentation](https://help.syncfusion.com/maui/datagrid/overview), where you can find more information about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples. Please refer to this [link](https://www.syncfusion.com/maui-controls/maui-datagrid) to learn about the essential features of Syncfusion .NET MAUI DataGrid (SfDataGrid).
35+
36+
##### Conclusion
37+
38+
I hope you enjoyed learning about how to perform indirect editing using a template column in the .NET MAUI DataGrid (SfDataGrid).
39+
40+
You can refer to our [.NET MAUI DataGrid’s feature tour](https://www.syncfusion.com/maui-controls/maui-datagrid) page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data. For current customers, you can check out our .NET MAUI components on the [License and Downloads](https://www.syncfusion.com/account/downloads) page. If you are new to Syncfusion, you can try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components. If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://support.syncfusion.com/account/login?ReturnUrl=%2Faccount%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dc54e52f3eb3cde0c3f20474f1bc179ed%26redirect_uri%3Dhttps%253A%252F%252Fsupport.syncfusion.com%252Fagent%252Flogincallback%26response_type%3Dcode%26scope%3Dopenid%2520profile%2520agent.api%2520integration.api%2520offline_access%2520kb.api%26state%3D8db41f98953a4d9ba40407b150ad4cf2%26code_challenge%3DvwHoT64z2h21eP_A9g7JWtr3vp3iPrvSjfh5hN5C7IE%26code_challenge_method%3DS256%26response_mode%3Dquery) or [feedback portal](https://www.syncfusion.com/feedback/maui?control=sfdatagrid), or the feedback portal. We are always happy to assist you!

SfDataGridSample.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34309.116
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfDataGridSample", "SfDataGridSample\SfDataGridSample.csproj", "{B98BD67C-738A-4295-9C50-C99E9AF5C281}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{B98BD67C-738A-4295-9C50-C99E9AF5C281}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {B0D9A0CE-D9C3-4CC3-9746-DDFB2608D4B2}
26+
EndGlobalSection
27+
EndGlobal

SfDataGridSample/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:SfDataGridSample"
5+
x:Class="SfDataGridSample.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>

SfDataGridSample/App.xaml.cs

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

SfDataGridSample/AppShell.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="SfDataGridSample.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:SfDataGridSample"
7+
Shell.FlyoutBehavior="Disabled"
8+
Title="SfDataGridSample">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>

SfDataGridSample/AppShell.xaml.cs

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

SfDataGridSample/MainPage.xaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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:syncfusion="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
5+
xmlns:local="clr-namespace:SfDataGridSample"
6+
x:Class="SfDataGridSample.MainPage">
7+
8+
<ContentPage.BindingContext>
9+
<local:EmployeeViewModel />
10+
</ContentPage.BindingContext>
11+
12+
<syncfusion:SfDataGrid x:Name="dataGrid"
13+
ItemsSource="{Binding Employees}"
14+
AutoGenerateColumnsMode="None"
15+
DefaultColumnWidth="155">
16+
<syncfusion:SfDataGrid.Columns>
17+
<syncfusion:DataGridTextColumn MappingName="EmployeeID"
18+
HeaderText="Employee ID"/>
19+
<syncfusion:DataGridTemplateColumn MappingName="Name">
20+
<syncfusion:DataGridTemplateColumn.CellTemplate>
21+
<DataTemplate>
22+
<Entry x:Name="label"
23+
Text="{Binding Name}"
24+
TextColor="Black"
25+
HorizontalOptions="FillAndExpand"
26+
VerticalOptions="FillAndExpand" />
27+
</DataTemplate>
28+
</syncfusion:DataGridTemplateColumn.CellTemplate>
29+
</syncfusion:DataGridTemplateColumn>
30+
<syncfusion:DataGridTextColumn MappingName="IDNumber"
31+
HeaderText="ID Number" />
32+
</syncfusion:SfDataGrid.Columns>
33+
</syncfusion:SfDataGrid>
34+
35+
</ContentPage>

SfDataGridSample/MainPage.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.Maui;
2+
using Syncfusion.Maui.Data;
3+
using Syncfusion.Maui.DataGrid;
4+
using Syncfusion.Maui.DataGrid.Helper;
5+
6+
namespace SfDataGridSample
7+
{
8+
public partial class MainPage : ContentPage
9+
{
10+
public MainPage()
11+
{
12+
InitializeComponent();
13+
}
14+
15+
}
16+
}

SfDataGridSample/MauiProgram.cs

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

SfDataGridSample/Model/Employee.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.ComponentModel;
2+
3+
namespace SfDataGridSample
4+
{
5+
public class Employee
6+
{
7+
public string EmployeeID { get; set; }
8+
public string Name { get; set; }
9+
public long IDNumber { get; set; }
10+
public string Title { get; set; }
11+
public int ContactID { get; set; }
12+
public DateTime BirthDate { get; set; }
13+
public string MaritalStatus { get; set; }
14+
public string Gender { get; set; }
15+
public DateTime HireDate { get; set; }
16+
public int SickLeaveHours { get; set; }
17+
public double Salary { get; set; }
18+
public string LoginID { get; set; }
19+
public int ManagerID { get; set; }
20+
public bool EmployeeStatus { get; set; }
21+
public int Rating { get; set; }
22+
}
23+
24+
}

0 commit comments

Comments
 (0)