0

私は剣道が初めてで、数日から剣道グリッドに検索データを入力する方法を見つけようとしています。私の場合は次のとおりです。

私は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」をサーバーに送信できません!

4

1 に答える 1

0

私は次のことを理解しています。サーバーで結果を返すメソッドを取得する場合、渡されたパラメーターを取得できる唯一の方法は、メソッドの本体で Response.Form または Response.QueryString を使用することです。次のように引数を取得できるように、そのメソッドに引数を渡すにはどうすればよいですか。

public JsonResult GetBillingReportResults(string billingCriteria)
{
    string criteria = Request.Form["billingCriteria"]; //I can do it like this, but I want to pass the arguments as method parameters
}
于 2012-08-14T13:12:33.413 に答える