簡體   English   中英

如何在ASP.NET中的Kendo Web方法數據源中傳遞參數?

[英]How to pass parameters in kendo web method data source in asp.net?

我有一個asp.net應用程序。 我正在使用kendo子彈圖表。 它是在.net Framework 2.0中開發的,因此wcf服務無法正常工作。 這就是為什么我使用Web方法綁定遠程數據的原因。

我想在kendo Web方法數據源URL中傳遞ac#變量的值,但是它不起作用。

這是我的代碼,

var month = "<%= month %>";

dataSource: {
  type: "json",
  transport: {
    read: {
      type: "POST",
      url: "Default.aspx/FetchCounts",
      contentType: 'application/json; charset=utf-8',
      datatype: "json"
    }
  },
  serverFiltering: false,
  serverSorting: false,
  schema: {
    //data: "d",
    data: month,
    model: {
      fields: {
        current: { type: "string" },
        target: { type: "string" }
      }
    }
  }
},

這是行不通的。

我不知道如何讓它發揮作用。

您正在Kendo UI DataSource定義的錯誤位置定義data參數。 參考 這是應該如何設置:

dataSource: {
  type: 'json',
  transport: {
    read: {
      type: 'POST',
      url: 'Default.aspx/FetchCounts',
      contentType: 'application/json; charset=utf-8',
      datatype: 'json',
      data: function () {
        return { 
          month: month 
        };
      }
    }
  },
  serverFiltering: false,
  serverSorting: false,
  schema: {
    //...
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM