Articles in this section
Category / Section

How to pass additional parameter when using DataManager in ASP.NET Core Grid?

2 mins read

 

This knowledge base explains the way how to pass additional parameter when using ASP.NET Core DataManager in grid.

We can have achieved it by using addParams method of ejQuery.

RAZOR

<ej-grid id="FlatGrid" allow-paging="true" action-begin="begin">
    <e-datamanager url="/Home/DataSource" adaptor="UrlAdaptor"/>
    <e-columns>
        <e-column field="OrderID" header-text="Order ID" is-primary-key="true" text-align="Right" width="75"></e-column>
        <e-column field="EmployeeID" header-text="Employee ID" text-align="Right"  width="75"></e-column>
        <e-column field="CustomerID" header-text="Customer ID" text-align="Right" width="75"></e-column>
        <e-column field="Ship City" header-text="Ship City" text-align="Right" width="75"></e-column>
    </e-columns>
</ej-grid>

 

JS

In “action-begin” event of grid we have passed the additional parameter value to the server side (Controller side) using addParams method of ejQuery.

<script type="text/javascript">
    function begin(args) {
           args.model.query.addParams("ID", 10248);
    }
</script>

 

In server side we have inherited and shown the additional parameter value in Syncfusion DataManager class itself.

C#

        public class Test : DataManager       //inherit the class to show age as property of DataManager
        {
            public int ID { get; set; }        
        }

 

C#

Bind the data manager value using the inherited class name “Test”

public IActionResult DataSource([FromBody]Test dm)
        {
           IEnumerable Result = _context.Orders.Take(100).ToList();
            var count = _context.Orders.AsQueryable().Count();
            DataOperations operation = new DataOperations();
            DataResult result = new DataResult();
            if (dm.Skip != 0)
            {
                Result = operation.PerformSkip(Result, dm.Skip);
            }
            if (dm.Take != 0)
            {
                Result = operation.PerformTake(Result, dm.Take);
            }
            result.result = Result;
            result.count = count;
            return Json(result)
        }
    public class DataResult
        {
             public IEnumerable result { get; set; }
            public int count { get; set; }
        }

 

C:\Users\Manisankar.durai\Desktop\sshot-1.png

Figure 1: Additional parameter in DataManager class 


Conclusion

I hope you enjoyed learning about how to pass additional parameter when using DataManager in ASP.NET Core Grid.

You can refer to our ASP.NET Core Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.  You can also explore our ASP.NET Core Grid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied