We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Web (Essential JS2), ASP.NET Core Razor Pages, Grid, UrlAdaptor

Thread ID:

Created:

Updated:

Platform:

Replies:

140738 Nov 5,2018 08:54 AM UTC Nov 20,2018 03:56 AM UTC ASP.NET Core - EJ 2 7
loading
Tags: Grid
Costa
Asked On November 5, 2018 12:06 PM UTC

Hi! You gave an example for the ej-grid: How to use UrlAdaptor in Asp.Net Core Razor Page?
Could you give a similar example for the ejs-grid?
I can't configure the Anti-forgery token validation for the ejs-grid.
Thanks.

Mohammed Farook J [Syncfusion]
Replied On November 8, 2018 07:36 AM UTC

Hi Costa, 
 
Thanks for contacting Syncfusion support.  
 
We have analyzed your query and created a sample based on you requirement. In the below sample, we have rendered the Essential JS2 Grid component in ASP.NET core with Razor pages and URLAdaptor in Grid. Kindly refer to the below code example, sample and documentations for more information. 
 
[Index.cshtml]  

<ejs-grid id="Grid" allowPaging="true" . . .>  
    <e-data-manager url="/Index?handler=DataSource" insertUrl="/Index?handler=Insert" updateUrl="/Index?handler=Update" removeUrl="/Index?handler=Delete"  adaptor="UrlAdaptor"></e-data-manager>  
    . . . 
</ejs-grid>  

[Index.cshtml.cs]  

public class IndexModel : PageModel  
    {  
        public void OnGet()  
        {  
  
        }  
        public JsonResult OnPostDataSource([FromBody]Data dm)  
        {  
            . . . 
            return dm.requiresCounts ? new JsonResult(new { result = data.Skip(dm.skip).Take(dm.take), count = count }) : new JsonResult(data);  
        }  

  
Documentation  
 
Regards, 
J Mohammed Farook.  


Costa
Replied On November 8, 2018 09:45 AM UTC

Strange, I did in my project the same, but I did not succeed... After you answered, everything worked)
Sorry to bother you. Thanks.

Mohammed Farook J [Syncfusion]
Replied On November 8, 2018 01:38 PM UTC

Hi Costa, 
 
Thanks for your update. 
 
We are happy to hear that the provided solution has been resolved your problem. 
 
Regards 
J Mohammed Farook 


danacon
Replied On November 16, 2018 04:50 PM UTC

Hi Mohammed,

I am also interested in using the url adaptor in razor pages so i downloaded the sample to see how it all works. However, I noticed that as all of the operations are now server-side, this means there are a lot of json structures being passed back and forth between page and server that i can see in fiddler e.g. for crud ops, i can see action/key/keyColumn fields, for filtering i can see complex where structures, etc.

I cannot find in the docs where these structures are defined, can you point me to them?

Thanks :)

Mohammed Farook J [Syncfusion]
Replied On November 19, 2018 10:26 AM UTC

Hi Dan, 
 
Query: I am also interested in using the url adaptor in razor pages so i downloaded the sample to see how it all works. However, I noticed that as all of the operations are now server-side, this means there are a lot of json structures being passed back and forth between page and server that i can see in fiddler e.g. for crud ops, i can see action/key/keyColumn fields, for filtering i can see complex where structures, etc. I cannot find in the docs where these structures are defined, can you point me to them? 
 
We have validated your query and created a sample based on your requirement. In Essential JavaScript 2 OnDemand Loading with UrlAdaptor you can use the default DataManagerRequest class which will contains the parameter of DataManager from the client.  With these parameters you can perform the server side actions like Paging, Filtering, Sorting etc. Please find the below code example and sample for your reference. 
 
[code example] 
public IActionResult GridDatasource([FromBody]DataManagerRequest dm) 
        { 
            IEnumerable<OrdersDetails> DataSource = OrdersDetails.GetAllRecords(); 
 
            DataOperations operation = new DataOperations(); 
            if (dm.Search != null && dm.Search.Count > 0) 
            { 
                DataSource = operation.PerformSearching(DataSource, dm.Search);  //Search 
            } 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
            { 
                DataSource = operation.PerformSorting(DataSource, dm.Sorted); 
            } 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
            { 
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator); 
            } 
            int count = DataSource.Cast<OrdersDetails>().Count(); 
            if (dm.Skip != 0) 
            { 
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging 
            } 
            if (dm.Take != 0) 
            { 
                DataSource = operation.PerformTake(DataSource, dm.Take); 
            } 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
 
 
 
Please find the sample and documentation in below link. 
 
 
 
Please get back to us if you need further assistance. 
 
 
Regards, 
J Mohammed Farook 


danacon
Replied On November 19, 2018 03:26 PM UTC

Hi Mohammed, that's great many thanks!

Mohammed Farook J [Syncfusion]
Replied On November 20, 2018 03:56 AM UTC

Hi Dan, 
 
We are happy to hear that the provided solution has been resolved your problem. 
 
Please get back to us if you need further assistance from us. 
 
Regards, 
J Mohammed Farook 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;