私は剣道が初めてで、数日から剣道グリッドに検索データを入力する方法を見つけようとしています。私の場合は次のとおりです。
私はJavaScriptビューモデルを持っています:
sl.kendo = function () {
var billingReportViewModel = kendo.observable({
billingReportCriteria: [],
executeSearch: function (e) {
var $grid = $("#gridResults").data("kendoGrid");
$grid.dataSource.read();
$grid.refresh();
}
});
return {
billingReportViewModel: billingReportViewModel
}
} ();
そして、この関数を使用してサーバーからbillingReportCriteriaを初期化します:
var initCriteriaViewModel = function () {
$.ajax({
url: 'GetBillingReportCriteria',
type: "GET",
dataType: "json",
success: function (model) {
**$.extend(sl.kendo.billingReportViewModel.get("billingReportCriteria"), kendo.observable(model));**
// bind to the viewModel
kendo.bind($("#searchTable"), sl.kendo.billingReportViewModel);
}
});
}()
このbillingReportCriteriaをパラメーターとしてサーバーに送信するグリッドDataSourceを宣言するよりも:
var gridDataSource = new kendo.data.DataSource({
transport: {
read: {
url: "GetBillingReportResults",
data: JSON.stringify(sl.kendo.billingReportViewModel.get("billingReportCriteria")),
cache: false,
type: "POST"
}
},
schema: {
data: "Items",
total: 10 // total number of data items is returned in the "count" field of the response
}
});
そして、剣道グリッドを初期化します。
$("#gridResults").kendoGrid({
columns: [
{
field: "Name"
},
{
field: "Title"
}],
dataSource: gridDataSource,
autoBind: false
});
ビュー モデル 'executeSearch' から検索を実行すると、サーバーに移動しますが、billingReportCriteria は空です! F12 Chrome ツールから「billingReportViewModel」の値を確認するとすべて問題ないように見えますが、「sl.kendo.billingReportViewModel.billingReportCriteria」または「sl.kendo.billingReportViewModel.get("billingReportCriteria")」の値を確認すると -空ですが、たとえば 'sl.kendo.billingReportViewModel.get("billingReportCriteria.Name")' には正しい値があります。問題が何であるかを提案できますか?どういうわけか、正しい「billingReportCriteria」をサーバーに送信できません!