使用选择器时出现 Dgrid 错误 -renderedCollection.fetchRange 不是函数

Dgrid error when using selectors -renderedCollection.fetchRange is not a function

我正在尝试将 dgrid 示例与使用内存存储的选择器一起使用,但无法填充网格,我收到错误类型错误:renderedCollection.fetchRange 不是函数。请指教,如何解决这个问题

我编辑了 dstore/Memory。在网格中加载数据时仍有问题

 require([
   'dojo/_base/declare', 'dgrid/Grid', 'dgrid/Selector', 'dstore/Memory'
  ], function (declare, Grid, Selector, Memory) {


/* jshint maxlen: 300 */
var dataList = [
    { col1: 'normal', col2: false, col3: 'new', col4: 'But are not followed by two hexadecimal', col5: 29.91, col6: 10, col7: false },
    { col1: 'important1', col2: false, col3: 'new', col4: 'Because a % sign always indicates', col5: 9.33, col6: -5, col7: false },
    { col1: 'importan2t', col2: false, col3: 'read', col4: 'Signs can be selectively', col5: 19.34, col6: 0, col7: true },
    { col1: 'note1', col2: false, col3: 'read', col4: 'However the reserved characters', col5: 15.63, col6: 0, col7: true },
    { col1: 'normal4', col2: false, col3: 'replied', col4: 'It is therefore necessary', col5: 24.22, col6: 5.50, col7: true },
    { col1: 'important', col2: false, col3: 'replied', col4: 'To problems of corruption by', col5: 9.12, col6: -3, col7: true },
    { col1: 'note', col2: false, col3: 'replied', col4: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris', col5: 12.15, col6: -4, col7: false }
];


   var employeeStore = new Memory({data:dataList, idProperty: 'col1'});


// In 0.4, Selector already inherits Selection so you don't have to
var grid = new (declare([ Grid, Selector ]))({
    collection: employeeStore,
    columns: {
        col1: 'Column1',
        col2: 'Column 2'
    }
}, 'grid');

grid.startup();

});

这看起来不太像 dgrid 的示例之一。您正在使用 dojo/store/Memory,但 dgrid 0.4+ 原生支持 dstore,而不是 dojo/store

dstore/Memory 在功能上与 dojo/store/Memory 非常相似,因此您应该能够毫无问题地将其用于此示例。

我在我的项目中遇到了这个问题。 请参阅此示例。

define(["dojo/_base/declare",

"dgrid/OnDemandGrid",
"dgrid/extensions/ColumnHider",
"dojo/store/Memory",
"dstore/legacy/StoreAdapter",
"dgrid/Selection"


],
function (declare,
    OnDemandGrid, ColumnHider, Memory, StoreAdapter, Selection
) {
    return declare(null, {



        constructor: function (arg) {
            debugger;
            declare.safeMixin(this, arg);
        },


        startup: function () {

            debugger;
            var columns = [];

            columns.push({
                label: "FID",
                field: "FID",

                width: "auto",
            });
            debugger;
            columns.push({
                label: "PARK_NAME",
                field: "PARK_NAME",

                width: "auto",
            });


            var dataList = [
                { FID: '1', PARK_NAME: "park 1" },
                 { FID: '2', PARK_NAME: "park 2" }

            ];



            const dataStore = new StoreAdapter({
                objectStore: new Memory({
                    idProperty: "FID"
                })
            });
            dataStore.objectStore.data = dataList;
            debugger;

            var grid = new (declare([OnDemandGrid, Selection, ColumnHider
            ]))({
                    collection: dataStore,
                    bufferRows: Infinity,
                    selectionMode: 'extended',

                    columns: columns
                }, this.gridNode)


            grid.startup();



        },




    })
})

将此小部件添加到小部件文件夹中名为 AttributeGrid.js 的 javascript 文件中。 并通过 "widget/AttributeGrid"、

加载它

接下来使用它

 var newAttributeGrid = new AttributeGrid({

       gridNode: "fdatagird"

      });

'fdatagird'是Html元素的Id

对我有用。