0

我正在尝试将 kendoGrid 集成到主干视图上,这是我的视图代码:

App.Views.UsersManager = Backbone.View.extend({
  tagName: 'section',
  id: 'users-manager',
  className: 'tile',
  template: Handlebars.compile($('#profile-usersManager-template').html()),
  render: function () {
    console.log('usersManager.render -> collection', this.collection);
    var self = this;
    this.$el.html(this.template());
    var dataSource = new kendo.data.DataSource({
      transport: {
        read: {
          url: '/users',
          type: 'GET',
          dataType: 'json'
        },
        update: {
          url: '/users',
          type: 'PUT',
          dataType: 'json'
        }
      },
      schema: {
        data: 'data'
      },
      batch: true
    });
    this.$('table.users-manager').kendoGrid({
      scrollable: false,
      sortable: true,
      dataSource: dataSource,
      toolbar: ["save"],
      editable: true,
      navigatable: true,
      // filterable: true,
    });
    return this;
  }
});

视图正确呈现,并且 kendoGrid 正确地从我的 SlimPHP 框架中获取我的用户数据,但是当我尝试修改网格的元素并点击“工具栏:[”保存“]”提供的“保存更改”按钮时,什么也没有发生了,即使在我的萤火虫控制台上......根本没有服务器通信。

我是剑道(以及骨干)开发的新手,也许我在语法上失败了?:卡住:

Atanas Korchev 回答后更新 这是我的 DataSource 更新:

var dataSource = new kendo.data.DataSource({
  transport: {
    read: {
      url: '/users',
      type: 'GET',
      dataType: 'json'
    },
    update: {
      url: '/users',
      type: 'PUT',
      dataType: 'json'
    }
  },
  schema: {
    data: 'data',
    model: {
      id: 'id',
      fields: {
        email: {},
        name: {},
        surname: {},
        rank: {},
        type: {}
      }
    }
  },
  batch: true
});

那不能解决我的问题,我想注意到我的 php 代码实际上是这样的:

$app->put('/users', function () use ($app, $db) {
  exit('put ok');
});

只是为了看看客户端/服务器通信是否有效......我知道这将是一个错误,但我也看不到任何萤火虫错误,比如“保存更改”按钮没有事件......(我会尝试Dennis Rongo 的建议..但我不认为是解决方案...)

对不起,我的英语不好

4

2 回答 2

1

尝试在 DataSource设置中描述您的模型:

schema: {
   data: 'data',
   model: {
      id: "MyId"      
   }
}

您至少需要指定id.

于 2013-02-04T08:51:16.657 回答
0

通过从模式对象中删除 data: 'data' 来解决,这里有链接kendoGrid 批量编辑

于 2013-02-05T04:20:25.773 回答