- Home
- Forum
- Angular - EJ 2
- How to set grid to send query filter string via POST method inside body of request
How to set grid to send query filter string via POST method inside body of request
Hello,
I am using Syncfusion Grid in Angular-2 enviroment and want to include filtering.
Is there a setting for grid, or it's datamanager that tells grid to use post method and send query string in the body of a grid.
Also, does grid have limitation in the lenght of request uri?
I am using Syncfusion Grid in Angular-2 enviroment and want to include filtering.
Is there a setting for grid, or it's datamanager that tells grid to use post method and send query string in the body of a grid.
Also, does grid have limitation in the lenght of request uri?
SIGN IN To post a reply.
3 Replies
DR
Dhivya Rajendran
Syncfusion Team
May 16, 2018 12:51 PM UTC
Hi Jan,
Thanks for contacting Syncfusion support.
Query1: I am using Syncfusion Grid in Angular-2 enviroment and want to include filtering.
We have analyzed your requirement and prepared a sample for your reference. In the below sample we have enabled the filtering feature in Grid and handled the filter operation in server side. When you filter the column in Grid the POST request will automatically send to the server.
Kindly refer to the below sample and code example for more information.
[fetchdata.component.html]
|
<ejs-grid #grid [dataSource]='data' [allowFiltering] ='true' [allowPaging]='true'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' isPrimaryKey='true' width=120></e-column>
<e-column field='EmployeeID' headerText='Employee ID' width=150></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=150></e-column>
. . . . .
</e-columns>
</ejs-grid> |
[Homecontroller.cs]
|
public IActionResult UrlDatasource([FromBody]Data dm)
{
var order = OrdersDetails.GetAllRecords();
var Data = order.ToList();
int count = order.Count();
if (dm.where != null && dm.where.Count > 0 && dm.where[0].predicates != null)
{
for (var i = 0; i < dm.where[0].predicates.Count; i++)
{
switch (dm.where[0].predicates[i].field)
{
case "OrderID":
Data = (from cust in Data
select cust).ToList();
break;
. . . . .
}
count = Data.Count;
}
}
return dm.requiresCounts ? Json(new { result = Data.Skip(dm.skip).Take(dm.take), count = count }) : Json(Data); }
|
Help documentation: https://ej2.syncfusion.com/16.1.37/angular/documentation/grid/filtering.html
Query2 : does grid have limitation in the lenght of request uri?
No, Grid does not have any limitation with URL length.
If we misunderstood your query, could you please provide more information regarding your requirement it will be more helpful for us to provide a better solution as soon as possible.
Regards,
R.Dhivya
R.Dhivya
JP
Jan Poljovka
May 16, 2018 01:18 PM UTC
Thank You for your answer.
It was helpful.
It was helpful.
DR
Dhivya Rajendran
Syncfusion Team
May 17, 2018 01:16 PM UTC
Hi Jan,
Thanks for your update.
We are happy to hear that the provided solution was helpful to achieve your requirement.
Please get back to us if you need further assistance on this.
Regards,
R.Dhivya
R.Dhivya
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JP Jan Poljovka
- May 14, 2018 03:09 PM UTC
- May 17, 2018 01:16 PM UTC