私は jQuery AJAX に精通しており、常に使用しています。Kendo UI は、jQuery とその AJAX の使用の上に構築されています。jQuery を使用すると、簡単に HttpHandler にパラメーターを渡すことができます。次の操作を行うだけです。
JQUERY AJAX の使用:
$.ajax({
complete: self.onComplete,
data: { SiteId: 777 }, // <--- this gets appended to the post
dataType: 'json',
error: self.onError,
success: self.onSuccess,
url: self.url
});
私の問題:
KendoUI の同等の呼び出しdata
(上記) を見つけようとしています。
- グリッドには HttpHandler から返されたデータが入力されますが、
- パラメータが HttpHandler に渡されていない (以下を参照)
剣道コードは次のようになります。
<script type="text/javascript">
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
transport:
{
read: {
url: "Handlers/Attempt1Synch.ashx",
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "POST",
data: { SiteId: 777 }
}
// parameterMap: function (data, operation) {
// return JSON.stringify(data);
// }
},
schema: { data: "People" }
});
$("#grid").kendoGrid({
height: 360,
width: 500,
dataSource: dataSource,
groupable: true,
scrollable: true,
sortable: true,
pageable: true,
columns:
[{
field: "Id",
width: 0
},
{
field: "FirstName",
width: 90,
title: "First Name"
},
{
field: "LastName",
width: 90,
title: "Last Name"
},
{
width: 100,
field: "City"
},
{
field: "Title"
},
{
field: "BirthDate",
title: "Birth Date",
template: '#= kendo.toString(BirthDate,"dd MMMM yyyy") #'
},
{
width: 50,
field: "Age"
}]
});
});
</script>
<div id="grid">
</div>
私の HTTP ハンドラーは次のようになります。
public class Attempt1Synch : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var siteId = Convert.ToInt32(context.Request["SiteId"]);
var serializer = new JavaScriptSerializer();
var response = mock(siteId);
context.Response.ContentType = "text/json";
context.Response.Write(serializer.Serialize(response));
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}