Knockout.js 将FlattedTreeTableDataSource与CollectionTreeDataSource一起使用时出现问题

Knockout.js 将FlattedTreeTableDataSource与CollectionTreeDataSource一起使用时出现问题,knockout.js,requirejs,oracle-jet,Knockout.js,Requirejs,Oracle Jet,要求 带有分页的表(每个WS调用获取30行) 行扩展器-获取子集合 无限滚动的子表 我计划使用,ojTable,oj.Collection,oj.Model 我也有同样的问题。调试(很多次)后,发现oj.ModelsidAttribute指向一个不存在的字段 例如: var CustCollection = new oj.Collection.extend({ url : 'https://dev.example.com/app/rest/categories', model :

要求

  • 带有分页的表(每个WS调用获取30行)
  • 行扩展器-获取子集合
  • 无限滚动的子表
  • 我计划使用,ojTable,oj.Collection,oj.Model
    我也有同样的问题。调试(很多次)后,发现
    oj.Model
    s
    idAttribute
    指向一个不存在的字段

    例如:

    var CustCollection = new oj.Collection.extend({
        url : 'https://dev.example.com/app/rest/categories',
        model : new oj.Model.extend({
            parse : function __parseSearch(response) {
                console.log(response); // <-- CHECK HERE
                return response;
            },
            idAttribute : 'categoryId' // <-- FIX HERE
        }),
        comparator : 'categoryId' // <-- FIX HERE
    });
    
    self.CustColl(new CustCollection());
    self.searchDatasource(new oj.CollectionTableDataSource(self.CustColl()));
    
    var CustCollection=new oj.Collection.extend({
    网址:'https://dev.example.com/app/rest/categories',
    型号:新oj.model.extend({
    parse:function\uu parseSearch(响应){
    
    console.log(response);//您解决了这个问题吗?是在UI上第一次呈现数据还是在分页过程中发现了这个问题?它本身处于初始阶段。我相信这是OJET中的一个错误。不确定如何记录这个错误。我目前能够在DataGrid中显示根节点,但在扩展时,“collection.sort不是函数”错误。我注意到CollectionTree对象的_Promissions未定义。不确定这是否有帮助,但在内部源代码中,_fetchChildren()->range已设置为{“开始”:0,“计数”:21}。我假设,由于您没有覆盖此内容,因此传递给OJET组件的行数将不同,因此会出现错误。请告诉我这是否是问题所在。仅供参考:OJET v3.2.0中仍会出现这种情况感谢此回复。我对此进行了尝试,但由于我的idAttribute确实存在,我不会想到将c加倍在我的例子中,这是因为parse函数将我的响应转换为不同的命名格式(department_id到DepartmentId),而我错误地认为idAttribute需要反映响应,而不是解析的响应。
    define([
        "Collection"
        "../models/Code"
        ], function(Collection, Code){
            "use strict";
            var Codes = Collection.extend({
                url: "code",
                model: Code
            });
            return Codes;
    });
    
    self.codes = new Codes(null, collectionOptions);
    self.treeDataSource = new oj.CollectionTreeDataSource(
            {
                root:self.codes,
                parseMetadata:function(model){
                    var retObj = {};
                    retObj['key'] = model.id;
                    return retObj;
                },
                childCollectionCallback:function(col , model){
                ...
                }
            });
    
    self.treeTableDataSource = new oj.FlattenedTreeTableDataSource(new oj.FlattenedTreeDataSource(self.treeDataSource));
    self.dataSource = new oj.PagingTableDataSource ( self.treeTableDataSource );
    
    <table id="table" 
        data-bind="ojComponent: 
        {
            component: 'ojTable', 
            data: dataSource, 
            rowTemplate: 'row_temp', 
            columns:$component.columns
        }">
    </table>
    <div id="paging" data-bind="ojComponent: {component: 'ojPagingControl', data: $component.dataSource, pageSize: 10}">
    </div>
    <script type="text/html" id="row_temp">
        <tr>
          <td>
            <div data-bind="ojComponent: {
                component: 'ojRowExpander', 
                context: $rowContext}"></div>
          </td>
        </tr>
    </script>
    
    ojtable.js:8265 Uncaught (in promise) TypeError: Cannot read property 'toString' of undefined
        at oj.TableDomUtils.hashCode (http://127.0.0.1:8080/js/libs/ojet/oj/v2.0.2/debug/ojtable.js:8265:14)
        at _refreshTableBodyRow (http://127.0.0.1:8080/js/libs/ojet/oj/v2.0.2/debug/ojtable.js:5296:52)
        at ._refreshTableBodyRow (http://127.0.0.1:8080/js/libs/jquery/jqueryui-amd-1.11.4.min/widget.js:4:1032)
        at _refreshTableBody (http://127.0.0.1:8080/js/libs/ojet/oj/v2.0.2/debug/ojtable.js:5256:20)
        at ._refreshTableBody (http://127.0.0.1:8080/js/libs/jquery/jqueryui-amd-1.11.4.min/widget.js:4:1032)
        at _refreshAll (http://127.0.0.1:8080/js/libs/ojet/oj/v2.0.2/debug/ojtable.js:5155:14)
        at ._refreshAll (http://127.0.0.1:8080/js/libs/jquery/jqueryui-amd-1.11.4.min/widget.js:4:1032)
        at .<anonymous> (http://127.0.0.1:8080/js/libs/ojet/oj/v2.0.2/debug/ojtable.js:3826:18)
        at http://127.0.0.1:8080/js/libs/ojet/oj/v2.0.2/debug/ojtable.js:6681:39
    
    oj.CollectionNodeSet.prototype.getData = function(index)
    {
        this._checkRange(index);
        return this.collection.at(index).attributes;
    };
    
    Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
    
    var CustCollection = new oj.Collection.extend({
        url : 'https://dev.example.com/app/rest/categories',
        model : new oj.Model.extend({
            parse : function __parseSearch(response) {
                console.log(response); // <-- CHECK HERE
                return response;
            },
            idAttribute : 'categoryId' // <-- FIX HERE
        }),
        comparator : 'categoryId' // <-- FIX HERE
    });
    
    self.CustColl(new CustCollection());
    self.searchDatasource(new oj.CollectionTableDataSource(self.CustColl()));