Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 5 在使用kendoGrid创建实体期间,WebApi v2 Odata的JayData行为不正确_Asp.net Mvc 5_Kendo Grid_Jaydata_Asp.net Web Api Odata - Fatal编程技术网

Asp.net mvc 5 在使用kendoGrid创建实体期间,WebApi v2 Odata的JayData行为不正确

Asp.net mvc 5 在使用kendoGrid创建实体期间,WebApi v2 Odata的JayData行为不正确,asp.net-mvc-5,kendo-grid,jaydata,asp.net-web-api-odata,Asp.net Mvc 5,Kendo Grid,Jaydata,Asp.net Web Api Odata,这是我的控制器: public class ProductEntityController : EntitySetController< ProductEntity, int> { public IQueryable< ProductEntity> Get(ODataQueryOptions< ProductEntity> parameters) { return productL

这是我的控制器:

 public class ProductEntityController : EntitySetController<
 ProductEntity, int> 
     { 
         public IQueryable< ProductEntity> Get(ODataQueryOptions< ProductEntity> parameters)
         {
             return productList.AsQueryable();
         }
         public  ProductEntity Create(ProductEntity entity)
         {
             productList.Add(entity);

             return entity;
         } }

//---------------------------------------

this my JS code:



 var context = new $data.initService('/odata');
      context.then(function (db) {

      var dsD = db.ProductEntity.asKendoDataSource();

      grid=  $('#gridD').kendoGrid({
                 dataSource: dsD,
                 filterable: true,
                 sortable: true,
                 pageable: true,
                 selectable: true,
                 height: 400,
                 columns: [
                     { field: 'Name' },
                     { field: 'Created' },
                     { field: 'Index' },
                     { field: 'LargeNum' },
                     { command: ["edit", "destroy", "update"] }
                 ],
                 toolbar: ["create", "save", "cancel"],
                 editable: "inline"

           }).data("kendoGrid");


         }).fail(function (args) {  });
为什么在保存之前调用innerInstance? 我如何解决我的问题? 我在MVC5上使用Jaydata1.3.6和剑道ui以及webApi2 Odata
请帮助我

当我在客户端的创建模式下更改密钥字段ID的默认值时,出现了此问题。JayData将带有筛选器的GET请求发送到服务器。因此,由于我的实体上没有此Id,因此出现了和错误。然后将POST new实体发送到服务器。 结论:没有权限在kendoGrid中编辑您的密钥并在服务器上处理它

  create: function (options, model) {
     var query = self;
     query.entityContext.onReady().then(function () {
     if (model.length > 1) {
     ..............
     ..........
     }
     else {
     console.dir(ctx.storeToken);
     model[0]
     .innerInstance() // when i comment this line everything is gonna be ok

     .save(ctx.storeToken)
     .then(function () {
     options.success();
     })
     .fail(function () {
     console.log("error in create");
     options.error({}, arguments);
     });
     }
     });
     }