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. Image for the cookie policy date

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

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.

7 Replies

MF Mohammed Farook J Syncfusion Team 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.  



CO Costa 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.


MF Mohammed Farook J Syncfusion Team 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 



DA danacon 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 :)


MF Mohammed Farook J Syncfusion Team 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 



DA danacon November 19, 2018 03:26 PM UTC

Hi Mohammed, that's great many thanks!


MF Mohammed Farook J Syncfusion Team 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 


Loader.
Live Chat Icon For mobile
Up arrow icon