Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
151318 | Feb 6,2020 05:19 PM UTC | Feb 10,2020 01:18 PM UTC | JavaScript - EJ 2 | 3 |
![]() |
Tags: Grid |
@{
ViewData["Title"] = "Grid";
}
<div id="Grid">
</div>
<script type="text/javascript">
$(function () {
var data = new ej.data.DataManager({
url: '/api/Orders',
adaptor: new ej.data.WebApiAdaptor(),
crossDomain: true
});
var grid = new ej.grids.Grid({
dataSource: data,
allowPaging: true,
allowFiltering: true,
toolbar: ['Search'],
actionBegin: actionBegin,
pageSettings: { pageSize: 15 },
columns: [
{ field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120, isPrimaryKey: true },
{ field: 'EmployeeID', width: 140, headerText: 'Employee ID' },
{ field: 'ShipCountry', headerText: 'Ship Country', width: 140 }
]
});
grid.appendTo('#Grid');
});
</script>
<script>
function actionBegin(args) {
if (args.requestType === "filtering") {
this.query = this.query.addParams("requestType", args.requestType)
}
else if (args.requestType === "searching") {
this.query = this.query.addParams("requestType", args.requestType)
}
}
</script>
|
...
<script type="text/javascript">
$(function () {
...
var grid = new ej.grids.Grid({
dataSource: data,
allowPaging: true,
allowFiltering: true,
toolbar: ['Search'],
actionBegin: actionBegin,
pageSettings: { pageSize: 15 },
columns: [
...
]
});
grid.appendTo('#Grid');
});
</script>
<script>
function actionBegin(args) {
if (args.requestType === "filtering") {
if (this.query.params.length > 0) { //checked whether the params present or not
this.query.params = []; //emptied params
this.query = this.query.addParams("requestType", args.requestType);
} else {
this.query = this.query.addParams("requestType", args.requestType);
}
}
else if (args.requestType === "searching") {
if (this.query.params.length > 0) { //checked whether the params present or not
this.query.params = []; //emptied params
this.query = this.query.addParams("requestType", args.requestType);
} else {
this.query = this.query.addParams("requestType", args.requestType);
}
}
}
</script> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.