【问题标题】:can't figure out why my Kendogrid's transport doesn't invoke ajax call when I call Kendogrid's render当我调用 Kendogrid 的渲染时,无法弄清楚为什么我的 Kendogrid 的传输不调用 ajax 调用
【发布时间】:2015-12-04 19:17:01
【问题描述】:

当我调用 Kendogrid 的 render() 时,我无法弄清楚为什么我的 Kendogrid Transport 的读取没有调用 ajax 调用。除 Transport 的 read() 外,所有函数都被调用。我想需要一些第三只眼睛来指出我的代码中的错误。如果需要更多信息,请告诉我。花了一天的时间,还是不行。

这是我的 Transport 和 GridView

var Transport = KendoGridView.Transport.extend({

            read: function(options) {
                $.ajax({
                    url: this._grid.url+ '?' + $.param(_.extend({},
                        this._parameterMap(options.data)
                    )),
                    type: 'POST',
                    contentType: 'application/json',
                    data: JSON.stringify(myVariable),
                    success: function(response) {
                        options.success(response);
                    }
                });
            }
    });

    var MyGridView = KendoGridView.extend({
        _url : "abc/def/ghi",
        _model: MyModel, //My Backbone model
        _currentPage: 1,
        _transportCls: Transport

        initialize: function(options) {
            KendoGridView.prototype.initialize.apply(this, arguments);
        },

        render: function{
            KendoGridView.prototype.render.call(this);
        },

        _dataSourceConfig: function() {
            var config = KendoGridView.prototype._dataSourceConfig.call(this);
            return _.extend(config, {page: this._currentPage});
        },
    });

    return MyGridView;

我在我的应用程序中对其他网格做了类似的处理。所有其他的东西都是使用 require.js 定义的。我错过了什么吗?

【问题讨论】:

    标签: jquery ajax backbone.js kendo-grid kendo-ui-grid


    【解决方案1】:

    想通了。在渲染函数内部的父视图中,有一条线在 div 内渲染网格。

    render: function() {
        this.$el.html(template);
        this._myGridView.setElement(this.$("#myVariantDB- select-configured-grid")).render();
    
        return this;
    }
    

    发现没有 id 为 "#myVariantDB-select-configured-grid" 的 div 不可用时会出现错误。

    【讨论】:

      猜你喜欢
      • 2014-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-16
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      相关资源
      最近更新 更多