@using Microsoft.JSInterop
@using Syncfusion.EJ2.Blazor.Grids
<EjsGrid DataSource="@Orders" AllowSorting="true" AllowPaging="true" AllowGrouping="true" Toolbar="@(new List<string>() { "Add","Update", “Delete”})">
...
</EjsGrid>
@code{
[Inject]
IJSRuntime JsRuntime { get; set; }
...
protected override void OnAfterRender(bool firstRender)
{
this.JsRuntime.Ejs().LoadLocaleData("wwwroot/de.json").SetCulture("de");
}
}
|
npm install cldr-data
|
public class CustomAdaptor : DataAdaptor
{
...
public override object Read(DataManagerRequest dm, string key = null) //Handle the sort, filter, search, paging actions here
{
IEnumerable<OrdersDetails> DataSource = order;
if (dm.Search != null && dm.Search.Count > 0)
{
//You can handle your custom Search action codes instead of using PerformSearching
}
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
//You can handle your custom Sort action codes instead of using PerformSorting
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
//You can handle your custom filter action codes instead of using PerformFiltering
}
int count = DataSource.Cast<OrdersDetails>().Count();
if (dm.Skip != 0)
{
//You can handle your custom skip action codes for paging instead of using PerformSkip
}
if (dm.Take != 0)
{
//You can handle your custom take action codes for paging instead of using PerformTake
}
return dm.RequiresCounts ? new DataResult() { Result = DataSource, Count = count } : (object)DataSource; //Finally return the result after your custom operations, as like Result and Count pair
}
public override object Insert(DataManager dm, object value, string key)
{
//Handle your custom insert operation and return the value
return value;
}
public override object Remove(DataManager dm, object value, string keyField, string key)
{
//Handle your custom delete operation and return the value
return value;
}
public override object Update(DataManager dm, object value, string keyField, string key)
{
//Handle your custom update operation and return the value
return value;
}
}
|
protected override void OnAfterRender(bool firstRender)
{
string url = "http://cdn.syncfusion.com/content/json/de.json";
string filepath = @"D:\new.json";
using (WebClient json = new MyWebClient())
{
json.DownloadFile(url, filepath);
}
this.JsRuntime.Ejs().LoadLocaleData(filepath).SetCulture("de");
} |
Hey, to avoid opening a different topic, I have a problem preventing automatic SfGrid sort.
I created a CustomAdaptor component where I have overriden all the methods to just return DataSource as is, but regardless, my Grid gets sorted automatically when clicking on the column.
How do I prevent automatic sorting but leave AllowSorting as true?
Hi Amar,
We're currently closed this ticket and create new forum query for the last update.
Kindly follow the following forum for more update - https://forumassist.syncfusion.com/177771
Regards,
Sarveswaran PK