Skip to content

Commit de9b957

Browse files
samples
1 parent ddf494f commit de9b957

File tree

5 files changed

+346
-37
lines changed

5 files changed

+346
-37
lines changed

ej2-blazor-samples/Pages/Grids/TreeData.cs

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using ej2_blazor_samples;
@@ -601,4 +602,306 @@ public static List<BusinessObject> GetDefaultData()
601602
return BusinessObjectCollection;
602603
}
603604
}
605+
606+
public class ShipmentData
607+
{
608+
public string ID { get; set; }
609+
public string Name { get; set; }
610+
public int Units { get; set; }
611+
public string Category { get; set; }
612+
public int UnitPrice { get; set; }
613+
public int Price { get; set; }
614+
public string ShipmentCategory { get; set; }
615+
public DateTime ShippedDate { get; set; }
616+
public DateTime OrderDate { get; set; }
617+
public List<ShipmentData> Children { get; set; }
618+
619+
620+
public static List<ShipmentData> GetShipmentData()
621+
{
622+
623+
List<ShipmentData> DataCollection = new List<ShipmentData>();
624+
625+
ShipmentData Parent1 = new ShipmentData()
626+
{
627+
ID = "1",
628+
Name = "Order 1",
629+
Category = "Seafood",
630+
Units = 1395,
631+
UnitPrice = 47,
632+
Price = 65565,
633+
OrderDate = new DateTime(2017, 3, 2),
634+
ShippedDate = new DateTime(2017, 9, 2),
635+
ShipmentCategory = "Seafood",
636+
Children = new List<ShipmentData>()
637+
};
638+
639+
ShipmentData Child1 = new ShipmentData()
640+
{
641+
ID = "1.1",
642+
Name = "Mackerel",
643+
Category = "Frozen Seafood",
644+
Units = 235,
645+
UnitPrice = 12,
646+
Price = 2820,
647+
OrderDate = new DateTime(2017, 3, 3),
648+
ShippedDate = new DateTime(2017, 10, 3),
649+
ShipmentCategory = "Frozen Seafood"
650+
};
651+
652+
ShipmentData Child2 = new ShipmentData()
653+
{
654+
ID = "1.2",
655+
Name = "Yellowfin Tuna",
656+
Category = "Frozen Seafood",
657+
Units = 324,
658+
UnitPrice = 8,
659+
Price = 2592,
660+
OrderDate = new DateTime(2017, 3, 5),
661+
ShippedDate = new DateTime(2017, 10, 5),
662+
ShipmentCategory = "Frozen Seafood"
663+
};
664+
ShipmentData Child3 = new ShipmentData()
665+
{
666+
ID = "1.3",
667+
Name = "Herrings",
668+
Category = "Frozen Seafood",
669+
Units = 488,
670+
UnitPrice = 11,
671+
Price = 5368,
672+
OrderDate = new DateTime(2017, 8, 5),
673+
ShippedDate = new DateTime(2017, 5, 15),
674+
ShipmentCategory = "Frozen Seafood"
675+
};
676+
ShipmentData Child4 = new ShipmentData()
677+
{
678+
ID = "1.4",
679+
Name = "Preserved Olives",
680+
Category = "Edible",
681+
Units = 125,
682+
UnitPrice = 9,
683+
Price = 1125,
684+
OrderDate = new DateTime(2017, 6, 10),
685+
ShippedDate = new DateTime(2017, 6, 17),
686+
ShipmentCategory = "Edible"
687+
};
688+
ShipmentData Child5 = new ShipmentData()
689+
{
690+
ID = "1.5",
691+
Name = " Sweet corn Frozen ",
692+
Category = "Edible",
693+
Units = 223,
694+
UnitPrice = 7,
695+
Price = 1561,
696+
OrderDate = new DateTime(2017, 7, 12),
697+
ShippedDate = new DateTime(2017, 7, 19),
698+
ShipmentCategory = "Edible"
699+
};
700+
Parent1.Children.Add(Child1);
701+
Parent1.Children.Add(Child2);
702+
Parent1.Children.Add(Child3);
703+
Parent1.Children.Add(Child4);
704+
Parent1.Children.Add(Child5);
705+
706+
ShipmentData Parent2 = new ShipmentData()
707+
{
708+
ID = "2",
709+
Name = "Order 2",
710+
Category = "Products",
711+
Units = 1944,
712+
UnitPrice = 58,
713+
Price = 21233,
714+
OrderDate = new DateTime(2017, 1, 10),
715+
ShippedDate = new DateTime(2017, 1, 16),
716+
ShipmentCategory = "Seafood",
717+
Children = new List<ShipmentData>()
718+
};
719+
720+
ShipmentData Child6 = new ShipmentData()
721+
{
722+
ID = "2.1",
723+
Name = "Tilapias",
724+
Category = "Frozen Seafood",
725+
Units = 278,
726+
UnitPrice = 15,
727+
Price = 4170,
728+
OrderDate = new DateTime(2017, 2, 5),
729+
ShippedDate = new DateTime(2017, 2, 12),
730+
ShipmentCategory = "Frozen Seafood"
731+
};
732+
733+
ShipmentData Child7 = new ShipmentData()
734+
{
735+
ID = "2.2",
736+
Name = "White Shrimp",
737+
Category = "Frozen Seafood",
738+
Units = 560,
739+
UnitPrice = 7,
740+
Price = 3920,
741+
OrderDate = new DateTime(2017, 5, 22),
742+
ShippedDate = new DateTime(2017, 5, 29),
743+
ShipmentCategory = "Frozen Seafood"
744+
};
745+
ShipmentData Child8 = new ShipmentData()
746+
{
747+
ID = "2.3",
748+
Name = "Fresh Cheese",
749+
Category = "Dairy",
750+
Units = 323,
751+
UnitPrice = 12,
752+
Price = 3876,
753+
OrderDate = new DateTime(2017, 6, 8),
754+
ShippedDate = new DateTime(2017, 6, 15),
755+
ShipmentCategory = "Dairy"
756+
};
757+
ShipmentData Child9 = new ShipmentData()
758+
{
759+
ID = "2.4",
760+
Name = "Blue Veined Cheese",
761+
Category = "Dairy",
762+
Units = 370,
763+
UnitPrice = 15,
764+
Price = 5550,
765+
OrderDate = new DateTime(2017, 7, 10),
766+
ShippedDate = new DateTime(2017, 7, 17),
767+
ShipmentCategory = "Dairy"
768+
};
769+
ShipmentData Child10 = new ShipmentData()
770+
{
771+
ID = "2.5",
772+
Name = "Butter",
773+
Category = "Dairy",
774+
Units = 413,
775+
UnitPrice = 9,
776+
Price = 3717,
777+
OrderDate = new DateTime(2017, 9, 18),
778+
ShippedDate = new DateTime(2017, 9, 25),
779+
ShipmentCategory = "Dairy"
780+
};
781+
782+
Parent2.Children.Add(Child6);
783+
Parent2.Children.Add(Child7);
784+
Parent2.Children.Add(Child8);
785+
Parent2.Children.Add(Child9);
786+
Parent2.Children.Add(Child10);
787+
788+
ShipmentData Parent3 = new ShipmentData()
789+
{
790+
ID = "3",
791+
Name = "Order 3",
792+
Category = "Crystals",
793+
Units = 1944,
794+
UnitPrice = 58,
795+
Price = 21233,
796+
OrderDate = new DateTime(2017, 9, 10),
797+
ShippedDate = new DateTime(2017, 9, 20),
798+
ShipmentCategory = "Seafood",
799+
Children = new List<ShipmentData>()
800+
};
801+
802+
ShipmentData Child11 = new ShipmentData()
803+
{
804+
ID = "3.1",
805+
Name = "Lead glassware",
806+
Category = "Solid crystals",
807+
Units = 542,
808+
UnitPrice = 6,
809+
Price = 3252,
810+
OrderDate = new DateTime(2017, 2, 7),
811+
ShippedDate = new DateTime(2017, 2, 14),
812+
ShipmentCategory = "Solid crystals"
813+
};
814+
815+
ShipmentData Child12 = new ShipmentData()
816+
{
817+
ID = "3.2",
818+
Name = "Pharmaceutical Glass",
819+
Category = "Solid crystals",
820+
Units = 324,
821+
UnitPrice = 11,
822+
Price = 3564,
823+
OrderDate = new DateTime(2017, 4, 19),
824+
ShippedDate = new DateTime(2017, 4, 26),
825+
ShipmentCategory = "Solid crystals"
826+
};
827+
ShipmentData Child13 = new ShipmentData()
828+
{
829+
ID = "3.3",
830+
Name = "Glass beads",
831+
Category = "Solid crystals",
832+
Units = 254,
833+
UnitPrice = 16,
834+
Price = 4064,
835+
OrderDate = new DateTime(2017, 5, 22),
836+
ShippedDate = new DateTime(2017, 3, 22),
837+
ShipmentCategory = "Solid crystals"
838+
};
839+
840+
Parent3.Children.Add(Child11);
841+
Parent3.Children.Add(Child12);
842+
Parent3.Children.Add(Child13);
843+
844+
DataCollection.Add(Parent1);
845+
DataCollection.Add(Parent2);
846+
DataCollection.Add(Parent3);
847+
848+
return DataCollection;
849+
}
850+
}
851+
852+
853+
public class SelfReferenceData
854+
{
855+
public static List<SelfReferenceData> tree = new List<SelfReferenceData>();
856+
[Key]
857+
public int TaskID { get; set; }
858+
public string TaskName { get; set; }
859+
public DateTime StartDate { get; set; }
860+
public DateTime EndDate { get; set; }
861+
public String Progress { get; set; }
862+
public String Priority { get; set; }
863+
public int Duration { get; set; }
864+
public int? ParentItem { get; set; }
865+
public bool? isParent { get; set; }
866+
public SelfReferenceData() { }
867+
public static List<SelfReferenceData> GetTree()
868+
{
869+
if (tree.Count == 0)
870+
{
871+
int root = -1;
872+
for (var t = 1; t <= 15; t++)
873+
{
874+
Random ran = new Random();
875+
string math = (ran.Next() % 3) == 0 ? "High" : (ran.Next() % 2) == 0 ? "Release Breaker" : "Critical";
876+
string progr = (ran.Next() % 3) == 0 ? "Started" : (ran.Next() % 2) == 0 ? "Open" : "In Progress";
877+
root++;
878+
int rootItem = tree.Count + root + 1;
879+
tree.Add(new SelfReferenceData() { TaskID = rootItem, TaskName = "Parent Task " + rootItem.ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = true, ParentItem = null, Progress = progr, Priority = math, Duration = ran.Next(1, 50) });
880+
int parent = tree.Count;
881+
for (var c = 0; c < 10; c++)
882+
{
883+
root++;
884+
string val = ((parent + c + 1) % 3 == 0) ? "Low" : "Critical";
885+
int parn = parent + c + 1;
886+
progr = (ran.Next() % 3) == 0 ? "In Progress" : (ran.Next() % 2) == 0 ? "Open" : "Validated";
887+
int iD = tree.Count + root + 1;
888+
tree.Add(new SelfReferenceData() { TaskID = iD, TaskName = "Child Task " + iD.ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = (((parent + c + 1) % 3) == 0), ParentItem = rootItem, Progress = progr, Priority = val, Duration = ran.Next(1, 50) });
889+
if ((((parent + c + 1) % 3) == 0))
890+
{
891+
int immParent = tree.Count;
892+
for (var s = 0; s < 3; s++)
893+
{
894+
root++;
895+
string Prior = (immParent % 2 == 0) ? "Validated" : "Normal";
896+
tree.Add(new SelfReferenceData() { TaskID = tree.Count + root + 1, TaskName = "Sub Task " + (tree.Count + root + 1).ToString(), StartDate = new DateTime(1992, 06, 07), EndDate = new DateTime(1994, 08, 25), isParent = false, ParentItem = iD, Progress = (immParent % 2 == 0) ? "On Progress" : "Closed", Priority = Prior, Duration = ran.Next(1, 50) });
897+
}
898+
}
899+
}
900+
}
901+
}
902+
return tree;
903+
}
904+
}
905+
906+
604907
}

ej2-blazor-samples/Pages/Grids/TreeGrid/CheckboxColumn.razor

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
@page "/TreeGrid/CheckboxColumn"
22

33
@using Syncfusion.EJ2.RazorComponents.TreeGrid
4+
@using Syncfusion.EJ2.RazorComponents.Data
5+
@using Syncfusion.EJ2.RazorComponents.Grids
6+
@using Syncfusion.EJ2.RazorComponents
47

58
@*Hidden:Lines*@
69
@using ej2_blazor_samples
@@ -36,31 +39,29 @@
3639
<div class="col-lg-12 control-section">
3740
<div class="content-wrapper">
3841
<div class="row">
39-
@*<EjsTreeGrid ID="treegrid" ref="treeGrid" ChildMapping="Children" TreeColumnIndex="1" DataSource="@treedata" Columns="@treecolumns" AllowPaging="true" EnableHierarchySelection="true"></EjsTreeGrid>*@
40-
41-
<EjsTreeGrid ID="TreeGrid" DataSource="@treedata" height="380" ChildMapping="Children" AllowPaging="true" TreeColumnIndex="1" AutoCheckHierarchy="true">
42+
<EjsTreeGrid ID="TreeGrid" AllowPaging="true" ChildMapping="Children" TreeColumnIndex="1" AutoCheckHierarchy="true">
43+
<EjsDataManager Json="@treedata" Adaptor="Adaptors.JsonAdaptor"></EjsDataManager>
4244
<TreeGridColumns>
43-
<TreeGridColumn Field="TaskId" HeaderText="Task ID" Width="60" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
44-
<TreeGridColumn Field="TaskName" HeaderText="Task Name" Width="190" ShowCheckbox="true"></TreeGridColumn>
45+
<TreeGridColumn Field="TaskId" HeaderText="Task ID" Width="80" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
46+
<TreeGridColumn Field="TaskName" HeaderText="Task Name" Width="160" ShowCheckbox="true"></TreeGridColumn>
4547
<TreeGridColumn Field="StartDate" HeaderText=" Start Date" Format="yMd" Type="date" Width="90" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
46-
<TreeGridColumn Field="EndDate" HeaderText="End Date" Format="yMd" Type="date" Width="100" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
47-
<TreeGridColumn Field="Duration" HeaderText="Duration" Width="80" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
48+
<TreeGridColumn Field="Duration" HeaderText="Duration" Width="100" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
49+
<TreeGridColumn Field="Progress" HeaderText="Progress" Width="100" TextAlign="@Syncfusion.EJ2.RazorComponents.Grids.TextAlign.Right"></TreeGridColumn>
4850
<TreeGridColumn Field="Priority" HeaderText="Priority" Width="80"></TreeGridColumn>
4951
</TreeGridColumns>
5052
</EjsTreeGrid>
51-
5253
</div>
5354
</div>
5455
</div>
5556

56-
@functions{
57+
@code{
5758

5859
EjsTreeGrid treeGrid;
59-
60-
public List<TreeData.BusinessObject> treedata { get; set; }
60+
61+
public TreeData.BusinessObject[] treedata { get; set; }
6162

6263
protected override void OnInit()
6364
{
64-
this.treedata = TreeData.GetDefaultData().ToList();
65+
this.treedata = TreeData.GetDefaultData().Cast<TreeData.BusinessObject>().ToArray();
6566
}
6667
}

0 commit comments

Comments
 (0)