我想将数据从剑道网格发送到 sql 数据库,这是我的 javascript 视图模型代码:
  document.onreadystatechange = function () {
var viewModel = kendo.observable({
    products: new kendo.data.DataSource({
    schema: {
       //data:"Data",
        total: "Count",
        model: {
            Id: "Id",
            fields: {
                Id: { editable: true, type: "int" },
                ShortName: { editable:true, type: "string" },
                FullName: { editable: true, type: "string" },
                ContactPerson: { editable: true, type: "string" },
                CurrentCurrencyCode: { editable: true, type: "int" },
                Adress1: { editable: true, type: "string" },
                CompanyState: { editable: true, type: "string" },
                CompanyCity: { editable: true, type: "string" },
                CompanyCountry: { editable: true, type: "string" },
                ZipPostCode: { editable: true, type: "string" },
                TelArea: { editable: true, type: "string" }
            }
        }
    },
    batch: true,
    transport: {
        read: {
            url: "/api/Companies/GetAllCompanies",
            dataType: "json"
        },
        create:{
            url: "/api/Companies/SaveDefCompny", // here is a correct api url, which i want to call
            dataType: "json"
        },
        destroy: {
            url: "/api/Companies/Delete", 
            dataType: "json"
        },
        parameterMap: function (data, operation) {
            if (operation !== "read" && data) {
                return  kendo.stringify(data) ;
            }
        }
    }
})
});
kendo.bind(document.getElementById("example"), viewModel);
}
这是我将数据发布到数据库的控制器代码,但它没有通过单击创建或更新按钮来调用我的网格或控制器调用有什么问题?
    [HttpPost]
    public void SaveDefCompny(IEnumerable<DefCompanyDTO> DfCmpny1)
    {
        var result = new List<DefCompany>();
        using (var data = new RPDBEntities())
        {
            foreach (var productViewModel in DfCmpny1)
              {
                var product = new DefCompany
                {
                  Id = productViewModel.Id,
                    CurrentCurrencyCode = productViewModel.CurrentCurrencyCode,
                    ShortName= productViewModel.ShortName,
                    FullName= productViewModel.FullName,
                    ContactPerson= productViewModel.ContactPerson,
                    Address1= productViewModel.Address1,
                    CompanyCity= productViewModel.CompanyCity,
                    CompanyState= productViewModel.CompanyState,
                   CompanyCountry= productViewModel.CompanyCountry,
                   ZipPostCode= productViewModel.ZipPostCode,
                   TelArea= productViewModel.TelArea
                };
               result.Add(product);
               data.DefCompanies.Add(product);
          };
             data.SaveChanges();
        }
    }
url 是正确的,但即使在调试光标未转到 url 但网格读取所有值并显示在其中时,它也不会调用