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

Any sample on how to use the datamanager with asp.net core ?

I'd like to instantiate a data manger using taghelpers as follow:
<ejs-data id="dmanager" url="Assessments?handler=DataSource" adaptor="UrlAdaptor"></ejs-data>

The use it from javascript as usual :
var damanger = document.getElementById('dmanager').ej2_instances[0];

then call any methods that the data manager object might have (get data from server side handlers by sending queries, filtering, sorting...) and bind the results to my controls.

Is this possible ? Can you please provide any examples if it is ?

I'm using asp.net core with razor pages.

Thanks, M

4 Replies

HJ Hariharan J V Syncfusion Team April 29, 2019 09:28 AM UTC

Hi Moez, 

Thanks for contacting Syncfusion support. 

From your query we found that you need to provide the data source to Grid by using UrlAdaptor in razor page. We have prepared the Grid sample based on this requirement and you can find that sample from the below link, 

 
Also, please refer the following code snippet for further assistance, 
 
Grid: 
 
@Html.AntiForgeryToken() 
 
<ejs-grid id="Grid" allowPaging="true" load="onLoad" > 
    <e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Batch"></e-grid-editsettings> 
    <e-data-manager url="/Index?handler=DataSource" batchUrl="/Index?handler=BatchUpdate" adaptor="UrlAdaptor"></e-data-manager> 
    <e-grid-columns> 
       <e-grid-column field="ShipCity" headerText="Ship City" textAlign="Right" width="120"></e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 
 
<script> 
    function onLoad() { 
        this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }]; 
    } 
</script> 
 
Controller: 
 
namespace Razorpages.Pages 
{ 
    public class IndexModel : PageModel 
    { 
        public static List<Orders> order = new List<Orders>(); 
        public void OnGet() 
        { 
            if (order.Count == 0) 
                BindDataSource(); 
        } 
        public class Data 
        { 
            public bool requiresCounts { get; set; } 
            public int skip { get; set; } 
 
            public int EmployeeID { get; set; } 
            public int EmployeeName { get; set; } 
            public int take { get; set; } 
        } 
 
        public JsonResult OnPostDataSource([FromBody]Data dm) 
        { 
            var data = order; 
            int count = data.Cast<Orders>().Count(); 
            return dm.requiresCounts ? new JsonResult(new { result = data.Skip(dm.skip).Take(dm.take), count = count }) : new JsonResult(data); 
        } 
   } 
} 

Regards, 
Hariharan 



MO moez April 29, 2019 06:56 PM UTC

Hi Hariharan

Thank you for your response, but I was actually looking for examples demonstrating how to use the standalone Data Manager component (ejs-data tag).
I found examples on how to use the data manager in javascript, but not how to declaratively use the data manager in asp.net core.

Is that even doable ?

Thanks, Moez


HJ Hariharan J V Syncfusion Team April 30, 2019 12:52 PM UTC

Hi Moez,

Thanks for your update.

We have validated with our end and we have considered “Unable to use data manager tag helper as standalone” as a bug and logged a defect report for the same. We will include the defect fix in our upcoming May 15, 2019 patch release. 
 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 
 
https://www.syncfusion.com/feedback/6088/unable-to-use-data-manager-tag-helper-as-standalone
 
Until then we appreciate your patience.  

Regards, 
Hariharan 




PS Pavithra Subramaniyam Syncfusion Team June 10, 2019 06:20 PM UTC

Hi  moez, 

Thanks for your patience. 

We are glad to announce that  we have included the fix  for the issue “Unable to use data manager tag helper as standalone component” in our patch release (v17.1.48).  
 
Regards, 
Pavithra S. 


Loader.
Up arrow icon