Hi, i can not paging the grid result, the data is ok, but the paging not work, please help my:
This is my code page aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WebApplication3._default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Griglia</title>
<script type="text/javascript" src="Scripts/KendoUi/jquery.min.js"></script>
<script src="Scripts/KendoUi/kendo.all.min.js" type="text/javascript"></script>
<link href="Styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="Styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<style>
#clientsDb {
width: 692px;
height: 393px;
margin: 30px auto;
padding: 51px 4px 0 4px;
background: url('../Images/clientsDb.png') no-repeat 0 0;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="example" >
<div id="clientsDb">
<div id="grid"></div>
</div>
</div>
<script type="text/javascript">
$(function () {
$("#grid").kendoGrid({
dataSource: {
schema: {
data: "Comuni", total: "TotalCount", // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
model: { // define the model of the data source. Required for validation and property types.
id: "CapComId",
fields: {
CapComId: { editable: false, nullable: true },
CapComCod: { validation: { required: true} },
CapComCom: { validation: { required: true} }
}
}
},
transport: {
read: {
url: "default.aspx/ListaComuni", //specify the URL which data should return the records. This is the Read method of the Products.asmx service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
},
parameterMap: function (data, operation) {
if (operation != "read") {
// web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
return JSON.stringify({ comuni: data.models})
}
}
},
serverPaging: true,
serverFiltering: true,
pageSize:6
},
height: 300,
groupable: true,
scrollable: true,
sortable: true,
pageable: true,
columns: [{
field: "CapComCod",
width: 90,
title: "Cap"
}, {
field: "CapComCom",
title: "Comune"
}
]
});
});
</script>
</form>
</body>
</html>
and page code c#
The data is show ok , but the paging show 1 and not work..
Thanks
Aurelio
This is my code page aspx:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Griglia</title>
<script type="text/javascript" src="Scripts/KendoUi/jquery.min.js"></script>
<script src="Scripts/KendoUi/kendo.all.min.js" type="text/javascript"></script>
<link href="Styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="Styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<style>
#clientsDb {
width: 692px;
height: 393px;
margin: 30px auto;
padding: 51px 4px 0 4px;
background: url('../Images/clientsDb.png') no-repeat 0 0;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="example" >
<div id="clientsDb">
<div id="grid"></div>
</div>
</div>
<script type="text/javascript">
$(function () {
$("#grid").kendoGrid({
dataSource: {
schema: {
data: "Comuni", total: "TotalCount", // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
model: { // define the model of the data source. Required for validation and property types.
id: "CapComId",
fields: {
CapComId: { editable: false, nullable: true },
CapComCod: { validation: { required: true} },
CapComCom: { validation: { required: true} }
}
}
},
transport: {
read: {
url: "default.aspx/ListaComuni", //specify the URL which data should return the records. This is the Read method of the Products.asmx service.
contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
},
parameterMap: function (data, operation) {
if (operation != "read") {
// web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
return JSON.stringify({ comuni: data.models})
}
}
},
serverPaging: true,
serverFiltering: true,
pageSize:6
},
height: 300,
groupable: true,
scrollable: true,
sortable: true,
pageable: true,
columns: [{
field: "CapComCod",
width: 90,
title: "Cap"
}, {
field: "CapComCom",
title: "Comune"
}
]
});
});
</script>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Services;
namespace WebApplication3
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static IEnumerable<
Comuni
> ListaComuni()
{
using (var northwind = new DataClasses1DataContext())
{
var lista = northwind.CAPCOM.Where(row=> row.CapComId<
100
)
// Use a view model to avoid serializing internal Entity Framework properties as JSON
.Select(p => new Comuni()
{
CapComId = p.CapComId,
CapComCod = p.CapComCod,
CapComCom = p.CapComCom
})
.ToList();
return lista;
}
}
public class Comuni
{
public int CapComId { get; set; }
public string CapComCod { get; set; }
public string CapComCom { get; set; }
public int Total { get; set; }
}
}
}
The data is show ok , but the paging show 1 and not work..
I can not understand how I do, I help?
Aurelio