Hello,
I wanted to implement a custom sort in Grid, so I referred to the following forum.
https://www.syncfusion.com/forums/158251/custom-sort-on-grid-column
It was very helpful and I was able to implement the custom sort, but there is one problem that I cannot solve.
In the sample presented in the above forum, there is a scene where the DataSource is retrieved in the Read method.
// Implementing custom adaptor by extending the DataAdaptor class
public class CustomAdaptor : DataAdaptor
{
// Performs data Read operation
public override object Read(DataManagerRequest dm, string key = null)
{
IEnumerable
In this case, Orders, which is assigned as DataSource, is a static member of the outer class.
However, if this is static, won't multiple clients accessing the same page at the same time end up sharing the same value?
I would like to getting Orders as the DataSource is an instance member in the page component, but I don't know how.
Maybe I am making some basic misunderstanding.
Any help would be appreciated.
Regars,
Atsushi
|
<SfGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true">
<SfDataManager Adaptor="Adaptors.CustomAdaptor">
<AdaptorComponent GridData="Orders"></AdaptorComponent>
</SfDataManager>
<GridPageSettings PageSize="8"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" MinWidth="10" Width="120" MaxWidth="200"></GridColumn>
</GridColumns>
</SfGrid>
@code{
public List<Order> Orders { get; set; }
protected override void OnInitialized()
{
Orders = Enumerable.Range(0, 4).Select(x => new Order()
{
OrderID = 1000 + x,
Alphanumeric = (new string[] { "ToE1", "ToE2", "ToE13", "ToE14" })[x],
Numeric = x,
Freight = 2.1 * x,
OrderDate = DateTime.Now.AddDays(-x),
}).ToList();
}
|
Hi Vignesh,
It worked fine!
Thank you for all your help.