@@ -766,10 +766,7 @@ The Syncfusion Blazor DataGrid allows you to display information about the Grid
766766
767767### Show tooltip
768768
769- The Syncfusion Blazor DataGrid provides a built-in feature to display tooltips when hovering over header and content cells. You can enable this feature by setting the ` ShowTooltip ` property to ** true** in the DataGrid.
770- By default, it shows the cell value for both header and content cells. For special types like templates, it displays the row data of the corresponding cells.
771-
772- The following example demonstrates, how to set the ` ShowTooltip ` property in the DataGrid.
769+ The Syncfusion Blazor DataGrid provides a built-in feature to display tooltips when hovering over header and content cells. You can enable this feature by setting the ` ShowTooltip ` property to ** true** in the DataGrid. By default, it shows the cell value for both header and content cells. For special types like templates, it displays the row data of the corresponding cells.
773770
774771{% tabs %}
775772{% highlight razor tabtitle="Index.razor" %}
@@ -778,77 +775,70 @@ The following example demonstrates, how to set the `ShowTooltip` property in the
778775
779776<SfGrid DataSource =" @Orders " ShowTooltip =" true " Width =" 700 " >
780777 <GridColumns>
781- <GridColumn Field=@nameof(OrderData.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="90"></GridColumn>
778+ <GridColumn Field=@nameof(OrderData.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids. TextAlign.Right" Width="90"></GridColumn>
782779 <GridColumn Field=@nameof(OrderData.CustomerID) HeaderText="Customer ID" Width="80"></GridColumn>
783- <GridColumn Field=@nameof(OrderData.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="70"></GridColumn>
784- <GridColumn Field=@nameof(OrderData.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="90"></GridColumn>
780+ <GridColumn Field=@nameof(OrderData.Freight) HeaderText="Freight" Format="C2" TextAlign="Syncfusion.Blazor.Grids. TextAlign.Right" Width="70"></GridColumn>
781+ <GridColumn Field=@nameof(OrderData.OrderDate) HeaderText="Order Date" Format="d" Type="Syncfusion.Blazor.Grids. ColumnType.Date" TextAlign="Syncfusion.Blazor.Grids. TextAlign.Right" Width="90"></GridColumn>
785782 </GridColumns >
786783</SfGrid >
787784
788785@code {
789- private SfGrid<OrderData > Grid;
790786 public List<OrderData > Orders { get; set; }
791-
787+
792788 protected override void OnInitialized()
793789 {
794790 Orders = OrderData.GetAllRecords();
795- }
791+ }
796792}
797793
798794{% endhighlight %}
799- {% highlight c# tabtitle="Order .cs" %}
795+ {% highlight c# tabtitle="OrderData .cs" %}
800796
801797public class OrderData
798+ {
799+ public static List<OrderData > Orders = new List<OrderData >();
800+ public OrderData()
802801 {
803- public static List<OrderData > Orders = new List<OrderData >();
804- public OrderData()
805- {
806802
807- }
808- public OrderData( int? OrderID, string CustomerID, DateTime? OrderDate, double? Freight)
809- {
810- this.OrderID = OrderID;
811- this.CustomerID = CustomerID;
812- this.OrderDate = OrderDate;
813- this.Freight = Freight;
814- }
815- public static List<OrderData> GetAllRecords()
803+ }
804+ public OrderData( int? OrderID, string CustomerID, DateTime? OrderDate, double? Freight)
805+ {
806+ this.OrderID = OrderID;
807+ this.CustomerID = CustomerID;
808+ this.OrderDate = OrderDate;
809+ this.Freight = Freight;
810+ }
811+ public static List<OrderData> GetAllRecords()
812+ {
813+ if (Orders.Count() == 0)
816814 {
817- if (Orders.Count() == 0)
818- {
819- int code = 10;
820- for (int i = 1; i < 2; i++)
821- {
822- Orders.Add(new OrderData(10248, "VINET",new DateTime(1996,07,07), 32.38));
823- Orders.Add(new OrderData(10249, "TOMSP", new DateTime(1996, 07, 07), 92.38));
824- Orders.Add(new OrderData(10250, "HANAR", new DateTime(1996, 07, 07), 62.77));
825- Orders.Add(new OrderData(10251, "VICTE", new DateTime(1996, 07, 07), 12.38));
826- Orders.Add(new OrderData(10252, "SUPRD", new DateTime(1996, 07, 07), 82.38));
827- Orders.Add(new OrderData(10253, "CHOPS", new DateTime(1996, 07, 07), 31.31));
828- Orders.Add(new OrderData(10254, "RICSU", new DateTime(1996, 07, 07), 22.37));
829- Orders.Add(new OrderData(10255, "WELLI", new DateTime(1996, 07, 07), 44.34));
830- Orders.Add(new OrderData(10256, "RICSU", new DateTime(1996, 07, 07), 31.33));
831- code += 5;
832- }
833- }
834- return Orders;
815+ Orders.Add(new OrderData(10248, "VINET", new DateTime(2025, 07, 07), 32.38));
816+ Orders.Add(new OrderData(10249, "TOMSP", new DateTime(2025, 07, 07), 92.38));
817+ Orders.Add(new OrderData(10250, "HANAR", new DateTime(2025, 07, 07), 62.77));
818+ Orders.Add(new OrderData(10251, "VICTE", new DateTime(2025, 07, 07), 12.38));
819+ Orders.Add(new OrderData(10252, "SUPRD", new DateTime(2025, 07, 07), 82.38));
820+ Orders.Add(new OrderData(10253, "CHOPS", new DateTime(2025, 07, 07), 31.31));
821+ Orders.Add(new OrderData(10254, "RICSU", new DateTime(2025, 07, 07), 22.37));
822+ Orders.Add(new OrderData(10255, "WELLI", new DateTime(2025, 07, 07), 44.34));
823+ Orders.Add(new OrderData(10256, "RICSU", new DateTime(2025, 07, 07), 31.33));
835824 }
836- public int? OrderID { get; set; }
837- public string CustomerID { get; set; }
838- public DateTime? OrderDate { get; set; }
839- public double? Freight { get; set; }
825+ return Orders;
840826 }
827+ public int? OrderID { get; set; }
828+ public string CustomerID { get; set; }
829+ public DateTime? OrderDate { get; set; }
830+ public double? Freight { get; set; }
831+ }
841832
842833{% endhighlight %}
843834{% endtabs %}
844835
845- {% previewsample "https://blazorplayground.syncfusion.com/embed/htrSjFVnKuSghwyK ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5 " %}
836+ {% previewsample "https://blazorplayground.syncfusion.com/embed/LXBSNYMiAEMphkRe ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5 " %}
846837
847838### Tooltip template
848839
849- The Syncfusion Blazor DataGrid component provides a built-in option to customize tooltip content for both header and content cells. This can be achieved using the ` TooltipTemplate ` property, which accepts a ` RenderFragment ` under the ` GridTemplates ` component.
840+ The Syncfusion Blazor DataGrid component provides a built-in option to customize tooltip content for both header and content cells. This can be achieved using the ` TooltipTemplate ` property, which accepts a ` RenderFragment ` under the ` GridTemplates ` component. This feature allows you to display additional information about columns when users hover over them, enhancing the clarity and usability of the DataGrid.
850841
851- This feature allows you to display additional information about columns when users hover over them, enhancing the clarity and usability of the DataGrid.
852842Tooltip customization is supported through the ` TooltipTemplateContext ` , which provides access to the following built-in properties:
853843<ul >
854844 <li><strong>Value</strong> – Displays the content of the hovered cell: the column name for header cells or the cell value for content cells.</li>
@@ -865,19 +855,18 @@ The following sample demonstrates a custom tooltip implementation using the `Too
865855
866856@using Syncfusion.Blazor.Grids
867857
868- <SfGrid DataSource =" @GridData " Height =" 330 " ShowTooltip =" true " Width =" 700 " >
858+ <SfGrid DataSource =" @Orders " Height =" 330 " ShowTooltip =" true " Width =" 700 " >
869859 <GridTemplates>
870860 <TooltipTemplate>
871861 @{
872862 var tooltip = context as TooltipTemplateContext;
873- var order = tooltip?.RowData as OrdersDetails;
863+ var order = tooltip?.Data as OrdersDetails;
874864 if (tooltip?.RowIndex == -1)
875865 {
876866 if (tooltip.Value == "Order ID")
877867 {
878868 <span><strong>@tooltip.Value: </strong>Unique number used to identify each customer order.</span>
879869 }
880-
881870 else if (tooltip.Value == "Customer ID")
882871 {
883872 <div>
@@ -893,7 +882,6 @@ The following sample demonstrates a custom tooltip implementation using the `Too
893882 <span><strong>@tooltip.Value: </strong>Name of the city where the order is delivered.</span>
894883 }
895884 }
896-
897885 else
898886 {
899887 var fieldName = tooltip?.Column?.Field;
@@ -903,27 +891,23 @@ The following sample demonstrates a custom tooltip implementation using the `Too
903891 case nameof(order.OrderID):
904892 <p style="margin: 2px 0;">@((MarkupString)GetStatusMessage(order.Status, order.OrderDate))</p>
905893 break;
906-
907894 case nameof(OrdersDetails.CustomerID):
908895 <div>
909896 <p style="margin: 2px 0;">
910- <strong>EmailID : </strong><a href="mailto:@order.Email">@order.Email</a>
897+ <strong>Email : </strong><a href="mailto:@order.Email">@order.Email</a>
911898 </p>
912899 </div>
913900 break;
914-
915901 case nameof(OrdersDetails.Freight):
916- <p style="margin: 4px 0;">
917- <strong>Delivery Type: </strong>
918- @GetDeliveryType(order.Freight)
919- </p>
902+ <p style="margin: 4px 0;">
903+ <strong>Delivery Type: </strong>
904+ @GetDeliveryType(order.Freight)
905+ </p>
920906 break;
921-
922907 case nameof(OrdersDetails.ShipCity):
923- <span class="e-icons e-location"></span>
908+ <span class="e-icons e-location"></span>
924909 <strong>Country: </strong> @order.ShipCountry
925910 break;
926-
927911 default:
928912 <strong>@tooltip?.Column?.Field: </strong> @tooltip.Value
929913 break;
@@ -934,9 +918,9 @@ The following sample demonstrates a custom tooltip implementation using the `Too
934918 </TooltipTemplate>
935919 </GridTemplates>
936920 <GridColumns>
937- <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="90"></GridColumn>
921+ <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids. TextAlign.Right" Width="90"></GridColumn>
938922 <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer ID" Width="90"></GridColumn>
939- <GridColumn Field=@nameof(OrdersDetails.Freight) Format="C2" Width="80" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit"></GridColumn>
923+ <GridColumn Field=@nameof(OrdersDetails.Freight) Format="C2" Width="80" TextAlign="Syncfusion.Blazor.Grids. TextAlign.Right" EditType="EditType.NumericEdit"></GridColumn>
940924 <GridColumn Field=@nameof(OrdersDetails.ShipCity) HeaderText="Ship City" Width="100"></GridColumn>
941925 </GridColumns>
942926</SfGrid >
@@ -946,26 +930,14 @@ The following sample demonstrates a custom tooltip implementation using the `Too
946930 position : relative ;
947931 top : 2px ;
948932 }
949-
950933</style >
951934
952935@code {
953- public List<OrdersDetails > GridData { get; set; }
936+ public List<OrdersDetails > Orders { get; set; }
954937
955938 protected override void OnInitialized()
956939 {
957- GridData = new List<OrdersDetails>
958- {
959- new OrdersDetails { OrderID = 1001, CustomerID = "Nancy", Freight = 80, ProductName = "Laptop", OrderDate = DateTime.Now.AddDays(-1), ShipCity = "Reims", ShipCountry = "France", Status = "Delivered", Location = "France", Email = "[email protected] ", DeliveryDays = "5-7 days" }, 960- new OrdersDetails { OrderID = 1002, CustomerID = "Andrew", Freight = 120, ProductName = "Smartphone", OrderDate = DateTime.Now.AddDays(3), ShipCity = "Munster", ShipCountry = "Germany", Status = "Pending", Location = "Germany", Email = "[email protected] " , DeliveryDays = "3-4 days"}, 961- new OrdersDetails { OrderID = 1003, CustomerID = "Janet", Freight = 180, ProductName = "Tablet", OrderDate = DateTime.Now.AddDays(-3), ShipCity = "Charleroi", ShipCountry = "Belgium", Status = "Cancelled", Location = "Belgium", Email = "[email protected] " , DeliveryDays = "1-2 days"}, 962- new OrdersDetails { OrderID = 1004, CustomerID = "Margaret", Freight = 60, ProductName = "Monitor", OrderDate = DateTime.Now.AddDays(-4), ShipCity = "Lyon", ShipCountry = "France", Status = "Delivered", Location = "France", Email = "[email protected] " , DeliveryDays = "5-7 days"}, 963- new OrdersDetails { OrderID = 1005, CustomerID = "Steven", Freight = 130, ProductName = "Keyboard", OrderDate = DateTime.Now.AddDays(4), ShipCity = "Delhi", ShipCountry = "India", Status = "Pending", Location = "India", Email = "[email protected] " , DeliveryDays = "3-4 days"}, 964- new OrdersDetails { OrderID = 1006, CustomerID = "Michael", Freight = 220, ProductName = "Mouse", OrderDate = DateTime.Now.AddDays(-6), ShipCity = "Tokyo", ShipCountry = "Japan", Status = "Delivered", Location = "Japan", Email = "[email protected] " , DeliveryDays = "1-2 days" }, 965- new OrdersDetails { OrderID = 1007, CustomerID = "Robert", Freight = 90, ProductName = "Printer", OrderDate = DateTime.Now.AddDays(-7), ShipCity = "Toronto", ShipCountry = "Canada", Status = "Cancelled", Location = "Canada", Email = "[email protected] " , DeliveryDays = "5-7 days"}, 966- new OrdersDetails { OrderID = 1008, CustomerID = "Laura", Freight = 160, ProductName = "Camera", OrderDate = DateTime.Now.AddDays(1), ShipCity = "Sydney", ShipCountry = "Australia", Status = "Pending", Location = "Australia", Email = "[email protected] ", DeliveryDays = "1-2 days" }, 967- new OrdersDetails { OrderID = 1009, CustomerID = "Anne", Freight = 90, ProductName = "Laptop", OrderDate = DateTime.Now.AddDays(-9), ShipCity = "Reims", ShipCountry = "France", Status = "Delivered", Location = "France", Email = "[email protected] " ,DeliveryDays = "5-7 days" }, 968- };
940+ Orders = OrdersDetails.GetAllRecords();
969941 }
970942 private string GetStatusMessage(string status, DateTime? orderDate)
971943 {
@@ -986,26 +958,62 @@ The following sample demonstrates a custom tooltip implementation using the `Too
986958 else
987959 return "Premium Delivery";
988960 }
989- public class OrdersDetails
961+ }
962+
963+ {% endhighlight %}
964+ {% highlight c# tabtitle="OrderDetails.cs" %}
965+
966+ public class OrdersDetails
967+ {
968+ public static List<OrdersDetails > Orders = new List<OrdersDetails >();
969+ public OrdersDetails()
990970 {
991- public int? OrderID { get; set; }
992- public string? CustomerID { get; set; }
993- public DateTime? OrderDate { get; set; }
994- public double Freight { get; set; }
995- public string? ShipCity { get; set; }
996- public string? ShipCountry { get; set; }
997- public string? Status { get; set; }
998- public string? Location { get; set; }
999- public string? ProductName { get; set; }
1000- public string? Email { get; set; }
1001- public string? DeliveryDays { get; set; }
971+
972+ }
973+ public OrdersDetails(int OrderID, string CustomerID, double Freight, DateTime OrderDate, string ShipCity, string ShipCountry, string Status, string Location, string Email)
974+ {
975+ this.OrderID = OrderID;
976+ this.CustomerID = CustomerID;
977+ this.Freight = Freight;
978+ this.OrderDate = OrderDate;
979+ this.ShipCity = ShipCity;
980+ this.Status = Status;
981+ this.ShipCountry = ShipCountry;
982+ this.Location = Location;
983+ this.Email = Email;
984+ }
985+ public static List<OrdersDetails> GetAllRecords()
986+ {
987+ if (Orders.Count() == 0)
988+ {
989+ Orders.Add (new OrdersDetails (1001, "Nancy", 80, DateTime.Now.AddDays(-1), "Reims", "France", "Delivered", "France", "[email protected] ")); 990+ Orders.Add (new OrdersDetails (1002, "Andrew", 120, DateTime.Now.AddDays(3), "Munster", "Germany", "Pending", "Germany", "[email protected] ")); 991+ Orders.Add (new OrdersDetails (1003, "Janet", 180, DateTime.Now.AddDays(-3), "Charleroi", "Belgium", "Cancelled", "Belgium", "[email protected] ")); 992+ Orders.Add (new OrdersDetails (1004, "Margaret", 60, DateTime.Now.AddDays(-4), "Lyon", "France", "Delivered", "France", "[email protected] ")); 993+ Orders.Add (new OrdersDetails (1005, "Steven", 130, DateTime.Now.AddDays(4), "Delhi", "India", "Pending", "India", "[email protected] ")); 994+ Orders.Add (new OrdersDetails (1006, "Michael", 220, DateTime.Now.AddDays(-6), "Tokyo", "Japan", "Delivered", "Japan", "[email protected] ")); 995+ Orders.Add (new OrdersDetails (1007, "Robert", 90, DateTime.Now.AddDays(-7), "Toronto", "Canada", "Cancelled", "Canada", "[email protected] ")); 996+ Orders.Add (new OrdersDetails (1008, "Laura", 160, DateTime.Now.AddDays(1), "Sydney", "Australia", "Pending", "Australia", "[email protected] ")); 997+ Orders.Add (new OrdersDetails (1009, "Anne", 90, DateTime.Now.AddDays(-9), "Reims", "France", "Delivered", "France", "[email protected] ")); 998+ }
999+ return Orders;
10021000 }
1001+
1002+ public int OrderID { get; set; }
1003+ public string CustomerID { get; set; }
1004+ public DateTime OrderDate { get; set; }
1005+ public double Freight { get; set; }
1006+ public string ShipCity { get; set; }
1007+ public string ShipCountry { get; set; }
1008+ public string Status { get; set; }
1009+ public string Location { get; set; }
1010+ public string Email { get; set; }
10031011}
10041012
10051013{% endhighlight %}
10061014{% endtabs %}
10071015
1008- {% previewsample "https://blazorplayground.syncfusion.com/embed/BDryjujMCPDfWrVi ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5 " %}
1016+ {% previewsample "https://blazorplayground.syncfusion.com/embed/rtBItaiifNQmMncI ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5 " %}
10091017
10101018> By default, custom tooltips will be displayed if the ` ShowTooltip ` property is set to ** true** .
10111019
0 commit comments