2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
You can place a dropdown in the Grid pager using pager template feature along with the default pager and on change event of the dropdown, change the page size through set model of Grid.
Initially, append some li elements in the div tag and assign them as a targeID for the ejDropDownList and also include the input element in the e-pagercontainer.
ASPX
Code behind
MVC Razor
Controller
Within the dataBound event render the DropDownList and bind change event. In the change event, update the pageSize of the Grid through set model as follows.
The following screenshot will be displayed as the result of the above code example.
Figure: Dropdown in the Grid’s pager using pager template.
|
2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
What goes in the "Datasource: pagerData"?
function
change(args) {
var
gridObj = $("
#Grid").ejGrid("instance");
gridObj.option({ "pageSettings": { pageSize: parseInt(args.text) } });
gridObj.getPager().find("input").ejDropDownList({
selectedIndex: args.itemId,
change: "change",
dataSource: pagerData
});
}
In JavaScript you need to define:
var pagerData = [
Hi Chris,
We can bind the dataSource to the DropDownList control as text/value pair as shown in the following code example.
<script type="text/x-jsrender" id="template">
<div class="e-pagercontainer">
<input type="text" id="pager" />
</div>
</script>
<div id="Grid"></div>
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
allowPaging: true,
dataBound: 'dataBound',
pageSettings: { enableTemplates: true, template: "#template", showDefaults: true },
});
});
var pagerData = [
{ text: "9", value: 9 },
. . .
..
];
function dataBound(args) {
$('#pager').ejDropDownList({
change: "change",
value: this.model.pageSettings.pageSize,
dataSource: pagerData
});
}
function change(args) {
var gridObj = $("#Grid").ejGrid("instance");
gridObj.option({ "pageSettings": { pageSize: parseInt(args.text) } });
gridObj.getPager().find("input").ejDropDownList({
selectedIndex: args.itemId,
change: "change",
dataSource: pagerData
});
}
</script>
Refer to the sample demo, http://jsplayground.syncfusion.com/iosigynl
Regards,
Seeni Sakthi Kumar S.