<EjsGrid DataSource="@Orders" AllowPaging="true">
……………………………..
</EjsGrid>
@code{
public List<Order> Orders { get; set; }
protected override void OnInitialized()
{
Orders = Enumerable.Range(1, 75).Select(x => new Order()
{
OrderID = 1000 + x,
. . . .
}).ToList();
}
public class Order
{
public int? OrderID { get; set; }
. . . .
}
} |
<EjsTreeGrid DataSource="@DerivedData" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="1" TValue="BusinessObject">
<TreeGridColumns>
<TreeGridColumn Field="@nameof(BusinessObject.TaskId)" HeaderText="Task ID" Width="80" TextAlign="Syncfusion.EJ2.Blazor.Grids.TextAlign.Right"></TreeGridColumn>
<TreeGridColumn Field="@nameof(BusinessObject.TaskName)" HeaderText="Task Name" Width="160"></TreeGridColumn>
. . .
</TreeGridColumns>
</EjsTreeGrid>
@code{
public class BusinessObject
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public int Duration { get; set; }
. . .
}
public List<BusinessObject> TreeData = new List<BusinessObject>();
public List<DerivedClass> DerivedData = new List<DerivedClass>();
protected override void OnInitialized()
{
DerivedData.Add(new DerivedClass() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" });
DerivedData.Add(new DerivedClass() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" });
}
public class DerivedClass : BusinessObject { } //derived class from base class BusinessObject
} |
<h2>Derived Class Data 1</h2>
<EjsGrid TValue="Order" DataSource="@DerivedData1" AllowPaging="true">
<GridPageSettings PageSize="5"></GridPageSettings>
<GridColumns>
. . . . . .. . .
</GridColumns>
</EjsGrid>
<h2>Derived Class Data 2</h2>
<EjsGrid TValue="Order" DataSource="@DerivedData2" AllowPaging="true">
<GridPageSettings PageSize="5"></GridPageSettings>
<GridColumns>
. . . . . . . ..
</GridColumns>
</EjsGrid>
@code{
public List<DerivedClass1> DerivedData1 { get; set; }
public List<DerivedClass2> DerivedData2 { get; set; }
protected override void OnInitialized()
{
DerivedData1 = Enumerable.Range(1, 75).Select(x => new DerivedClass1()
{
. . . . . .. .
}).ToList();
DerivedData2 = Enumerable.Range(1, 75).Select(x => new DerivedClass2()
{
. . . . . .
}).ToList();
}
public class Order
{
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
}
public class DerivedClass1 : Order { }
public class DerivedClass2 : Order { }
} |
<EjsTreeGrid DataSource="@DerivedData" IdMapping="TaskId" ParentIdMapping="ParentId" TreeColumnIndex="1" TValue="BusinessObject">
<TreeGridColumns>
<TreeGridColumn Field="@nameof(BusinessObject.TaskId)" HeaderText="Task ID" Width="80" TextAlign="Syncfusion.EJ2.Blazor.Grids.TextAlign.Right"></TreeGridColumn>
<TreeGridColumn Field="@nameof(BusinessObject.TaskName)" HeaderText="Task Name" Width="160"></TreeGridColumn>
. . .
</TreeGridColumns>
</EjsTreeGrid>
@code{
public class BusinessObject
{
public int TaskId { get; set; }
public string TaskName { get; set; }
public int Duration { get; set; }
public int? ParentId { get; set; }
. . .
}
public List<BusinessObject> TreeData = new List<BusinessObject>();
public List<DerivedClass> DerivedData = new List<DerivedClass>();
protected override void OnInitialized()
{
DerivedData.Add(new DerivedClass() { TaskId = 1, TaskName = "Parent Task 1", Duration = 10, Progress = 70, ParentId = null, Priority = "High" });
DerivedData.Add(new DerivedClass() { TaskId = 2, TaskName = "Child task 1", Duration = 4, Progress = 80, ParentId = 1, Priority = "Normal" });
}
public class DerivedClass : BusinessObject { } //derived class from base class BusinessObject
}
|
<SfDropDownList TValue="string" TItem="ITestItem" DataSource="@AllItems" @bind-Value="@PropertyValue">
<DropDownListFieldSettings Text="Value" Value="Value"></DropDownListFieldSettings>
</SfDropDownList>
@code
{
public string PropertyValue { get; set; }
public interface ITestItem
{
}
public class TestItem<T> : ITestItem
{
public T Value { get; set; }
}
public List<ITestItem> AllItems
{
get
{
return new List<ITestItem>() {
new TestItem<string>() { Value = "a" },
new TestItem<string>() { Value = "b" }
};
}
} |