.Net Core MVC Grid CRUD

Hi,
I want to have CRUD sorted by search and display data with CRUD with SQL Database
I use the URL adapter according to the official documentation
But my return was obviously wrong.
Only json format appears on the screen after execution
Am i doing something wrong?
Can you give me an example?

Thank you for you help.
Best regards.

[View]


[Controller]





1 Reply

BS Balaji Sekar Syncfusion Team February 18, 2020 10:33 AM UTC

Hi Mina, 
 
Greetings from syncfusion support 
 
Based on your query we have prepared a sample with UrlAdaptor of Datamanager. You can map The CRUD operation in grid can be mapped to server-side Controller actions using the properties insertUrl, removeUrl and updateUrl. when using the UrlAdaptor, you need to return the data as JSON from the controller action and the JSON object must contain a property as result with dataSource as its value and one more property count with the dataSource total records count as its value. Please refer the below screenshot, code example and sample for more information. 
 
 
 
 
[DataGridController.cs] 
public ActionResult UrlDatasource([FromBody]DataManagerRequest dm) 
        { 
 
            IEnumerable DataSource = _context.Orders.ToList();  //set sql database as IEnumerable dataSource 
 
            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); 
            } 
            int count = DataSource.Cast<Orders>().Count(); 
            if (dm.Skip != 0)//Paging 
            { 
                DataSource = operation.PerformSkip(DataSource, dm.Skip);          
            } 
            if (dm.Take != 0) 
            { 
                DataSource = operation.PerformTake(DataSource, dm.Take); 
            } 
            
            return Json(new { result = DataSource, count = count }); 
        } 

 
 
 
 
Regards,
Balaji Sekar.
 


Loader.
Up arrow icon