SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 295 forks source link

_StoreMixin.js:33 TypeError: grid._renderedCollection.fetchRange is not a function(…) #1329

Closed beeant0512 closed 4 years ago

beeant0512 commented 8 years ago

when i create a Pagination grid throw the error , here is my code

var dataList = [ { col1: 'normal', col2: false, col3: 'new', col4: 'But are not followed by two hexadecimal', col5: 29.91, col6: 10, col7: false },...... ];

pageData.items = dataList;

var pageGrid = new (declare([Grid, Pagination]))({
  collection: pageData,
  columns: {
    id: "ID",
    col1: 'Column 1',
    col2: {label: 'Column2', sortable: false},
    col3: 'Column 3',
    col4: 'Column 4',
    col5: 'Column 5'
  },
  noDataMessage: "No results.",
  loadingMessage: "Loading..."
}, 'pageGridDemo');
raykendo commented 7 years ago

It looks like you're not using a dstore data store for your collection. It would be easier if we saw how pageData was created. If pageData was created using a dstore data object (like dstore/Memory), you would add the datalist like the following:

pageData.data = dataList;
msssk commented 4 years ago

You can see example code of how to use pagination in the dgrid Laboratory.

require([
    'dojo/_base/declare',
    'dstore/Memory',
    'dstore/Trackable',
    'dgrid/Grid',
    'dgrid/extensions/Pagination'
], function (declare, Memory, Trackable, Grid, Pagination) {
    var store = new (declare([Memory, Trackable]))({
        data: createData()
    });

    // Instantiate grid
    var grid = new (declare([Grid, Pagination]))({
        collection: store,
        columns: {
            First_Name: {
                label: 'First Name'
            },
            Last_Name: {
                label: 'Last Name'
            }
        }
    }, 'grid');

    grid.startup();

    function createData() {
        var data = [];
        var column;
        var i;
        var item;

        for (i = 0; i < 50; i++) {
            item = {};
            for (column in { First_Name: 1, Last_Name: 1 }) {
                item.id = i;
                item[column] = column + '_' + (i + 1);
            }
            data.push(item);
        }

        return data;
    }
});