2
我對jQuery AJAX非常熟悉並一直使用它。 Kendo UI建立在jQuery之上,並且使用了AJAX。與&傳遞參數的接口到一個HttpHandler是很容易使用jQuery,你只需做到以下幾點:如何使用Kendo UI將參數傳遞給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>
MY 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;
}
}
}
謝謝你的答案。你推薦任何關於Kendo UI的博客或教程。我發現Telerik的文檔和示例缺乏。 – 2014-10-31 19:31:32
不,我很抱歉我不得不通過這個使用'試錯法'來解決這個問題。是的,Telerik的文檔網站確實很糟糕。 – 2014-11-05 13:29:42