Articles in this section
Category / Section

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

2 mins read

 

This knowledge base explains the way how to pass additional parameter when using 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


Note:

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

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 (0)
Please sign in to leave a comment
Access denied
Access denied