【问题标题】:KoGrid not working in Durandal JS frameworkKoGrid 在 Durandal JS 框架中不起作用
【发布时间】:2013-12-29 09:51:05
【问题描述】:

如何在 durandal JS 视图页面中绑定 koGrid。下面给出的代码不起作用。

视图(html)

  <div id="functiontable" class="form-actions">
                        <div style="height: 200px" data-bind="koGrid: {
                                 data: items, columnDefs: [{ field: 'id', width: 140 },
                                    { field: 'name', width: 100 },
                                    { field: 'price', width: 150 }
                                ],
                            autogenerateColumns: false,
                            isMultiSelect: false,
                             enableSorting: true
                        }"></div>

                    </div>

视图模型(js)

define([ 'repositories/customerRepository', 'plugins/router', 'plugins/http', 'durandal/app', 'knockout'], function (customerRepository, router, http, app, ko) {
var items = ko.observableArray([
 { id: 1, name: "abc", price: "asds" },
{id:1,name:"abc",price:"asds"},
]);
return {
    router: router,
    items:items, 
    activate: function () {


    },
    attached: function (view) {

    },



};});

如果我从浏览器检查元素,网格会加载它的值。我不知道如何解决这个问题。谁能帮助我?

【问题讨论】:

    标签: javascript jquery asp.net-mvc knockout.js durandal


    【解决方案1】:

    项目需要实际返回才能被您的视图使用,所以:

    items: ko.observableArray([
           { id: 1, name: "abc", price: "asds" },
           {id:1,name:"abc",price:"asds"}
    ]),
    activate: function () {
    
    }
    

    提示 执行此操作时,请使用客户端调试器,例如 Chrome 网络工具(Chrome 中的 F12)——它会突出显示“项目”找不到。

    【讨论】:

      猜你喜欢
      • 2013-12-05
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多