KendoMobile MVVM kendo.observable,从JSON获取数据

时间:2013-11-23 22:26:45

标签: jquery json mvvm kendo-mobile

我遇到了如何从serwer(json)中恢复数据的工作或maby的问题。 我最初的想法是采用示例MusicStore并帮助自己重新获取数据并且卡住了......

查看

<!--Expositions Views-->
<div data-role="view" id="expositions-view" data-layout="base-layout" data-title="Expositions" data-show="app.expositionsView.viewModel">
    <ul id="expositions-listview" data-role="listview" data-bind="source: expositions" data-template="expositions-list-template" data-style="inset" data-auto-bind="true"></ul>
</div>
<!-- Templates -->

<script type="text/x-kendo-template" id="expositions-list-template">
    <a class="list-item" href="\#items-view?floorId=0&expositionId=\#= ExpositionId \#">
        <div>
            <div class="mp_list_thumb" style="background-image: url(http://82.160.41.133/Photo/GetPhoto/?id=#=PhotoId#&h=75&w=75); "></div>
            <p class="title">#= ExpositionName #</p>
            <p class="description">
                #= app.shortDesc(ExpositionDescription) #
            </p>
        </div>
        <span class="more">More...</span>
    </a>
</script>

观点来源

define(["jQuery", "kendo", "data", "utils"], function ($, kendo, data, utils) {
    return {
        onShow: function (e) {
            utils.log("expositions-view: onShow: " + e)
        },

        viewModel: kendo.observable({
            expositions: data.expositionsList
        })
    };
});

审阅数据......

define(["jQuery", "kendo", "config", "utils"], function ($, kendo, config, utils) {

    var _wcfSchemaData = function (data) {
        return data.Data;
    },

         _wcfSchemaTotal = function (data) {
             return data.Count;
         };

    var DataSourceConfig = function (url, sortField, options, dataType) {
        this.transport = {
            dataType: dataType,
            read: url
        };
        //this.sort = {
        //    field: sortField,
        //    dir: "asc"
        //};
        //$.extend(this, options || {});
    };

    DataSourceConfig.prototype = {
        //type: "json",
        schema: {
            data: _wcfSchemaData,
            total: _wcfSchemaTotal
        },
        requestStart: function () { if (this.pageSize() === undefined || this.page() === 1) { utils.showLoading(); } }, //infinite scrolling has its own, less obtrusive indicator
        requestEnd: function () { utils.hideLoading(); },
        error: function () { utils.hideLoading(); utils.showError("There was an error loading the data from the server. Please close the app and try again."); }
    };

    //var EndlessScrollDataSource = kendo.data.DataSource.extend({
    //    _observe: function (data) {
    //        if (this._page > 1) {
    //            this._data.push.apply(this._data, data);
    //            return this._data;
    //        }
    //        return kendo.data.DataSource.prototype._observe.call(this, data);
    //    }
    //});

    return {
        clear: function (dataSource) {
            dataSource.view().splice(0, dataSource.view().length);
        },

        expositionsList: new kendo.data.DataSource(new DataSourceConfig(config.expositionUrl + "?lang=pl-PL", "Name",null,'json')),

    };

});

我收到错误...未捕获TypeError:对象[object Object]没有方法'call'

我如何解决这个问题,使其成功 Jsonson在这里(Json)

寻求帮助

0 个答案:

没有答案