I have a data array with 165 elements, and I am showing them in an OnDemandGrid, sorted by a date field. However, when the grid shows up, only the last 140 elements in the data array are shown (i.e., the elements with the 140 most recent dates). Still, if I click the date header to reverse the sort, the first 140 elements show (i.e., the elements with the 140 oldest dates). So my guess is that somehow the mechanism of lazy loading is not working, still I don't get why only the last portion of the array is shown instead of the first. I am not using pagination, nor I set other options related to the size. Any suggestion?
The grid is added to a div which is already in the page:
<div id="navList" class="dgrid-autoheight"></div>
Here's the code for the grid, below you can find the data array:
function fillNavList(data) {
var columns =
[
{
field : "date",
label : L["date"]
},
{
field : "value",
label : L["value"]
},
{
field : "dateModification",
label : L["dateModification"]
},
{
field : "status",
label : L["status"]
},
{
field : "valueRefId",
label : L["valueRefId"]
}
];
require(
[
"dojo/on",
"dstore/Memory",
"dstore/Filter",
"dgrid/OnDemandGrid",
"dojo/_base/declare"
], function(on, Memory, Filter, OnDemandGrid, declare) {
var store = new Memory({
data : data
});
var navList = new (declare(
[
OnDemandGrid
]))({
columns : columns,
sort: "date",
collection : store,
addUiClasses : false
}, "navList");
});
}
And here's the data:
[{"date":"2000-01-31","value":96.02,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-02-28","value":100,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-03-29","value":92.48,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-04-30","value":93.91,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-05-31","value":100.25,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-06-28","value":107.65,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-07-31","value":114.06,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-08-30","value":120.26,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-09-30","value":126.43,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-10-31","value":116.66,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-11-29","value":110.73,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2002-12-31","value":119.37,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-01-31","value":135.13,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-02-28","value":144.88,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-03-31","value":126.29,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-04-30","value":128.12,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-05-30","value":137.91,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-06-30","value":127.41,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-07-31","value":119.34,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-08-29","value":119.42,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-09-30","value":127.37,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-10-31","value":146.88,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-11-28","value":146.48,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2003-12-31","value":154.32,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-01-30","value":160.79,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-02-27","value":174.37,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-03-31","value":178.51,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-04-30","value":157.99,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-05-31","value":146.95,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-06-30","value":145.87,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-07-30","value":145.27,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-08-31","value":136.25,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-09-30","value":146.82,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-10-29","value":147.94,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-11-30","value":162.19,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2004-12-31","value":154.17,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-01-31","value":147.57,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-02-28","value":148.36,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-03-31","value":151.77,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-04-29","value":137.69,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-05-31","value":132.07,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-06-30","value":139.09,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-07-27","value":148.3,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-08-31","value":152.43,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-09-30","value":173.12,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-10-31","value":163.36,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-11-30","value":188.31,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2005-12-30","value":204.03,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-01-31","value":226.65,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-02-28","value":220.54,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-03-31","value":249.33,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-04-28","value":277.9,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-05-31","value":266.03,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-06-30","value":249.8,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-07-31","value":236.82,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-08-31","value":241.44,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-09-29","value":243.85,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-10-06","value":243,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-10-31","value":243.54,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-11-30","value":244.9,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2006-12-29","value":248.81,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-01-31","value":250.2,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-02-28","value":237.24,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-03-30","value":216.31,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-04-30","value":221.92,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-05-31","value":232.35,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-06-29","value":243.63,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-07-31","value":202.47,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-08-31","value":163.19,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-09-28","value":169.58,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-10-31","value":192.84,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-11-30","value":176.27,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2007-12-31","value":191.2,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-01-31","value":232.59,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-02-29","value":299.72,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-03-31","value":275.87,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-04-30","value":252.21,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-05-30","value":265.71,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-06-30","value":288.32,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-07-31","value":234.16,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-08-29","value":218.41,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-09-30","value":243.7,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-10-31","value":354.57,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-11-28","value":379.28,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2008-12-31","value":399.38,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-01-30","value":405.77,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-02-27","value":405.65,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-03-31","value":392.02,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-04-30","value":370.42,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-05-29","value":365.6,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-06-30","value":340.71,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-07-31","value":338.9,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-08-31","value":375.67,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-09-30","value":380.63,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-10-30","value":350.71,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-11-30","value":388.24,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2009-12-31","value":375.85,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-01-29","value":361.39,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-02-26","value":335.54,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-03-10","value":318.26,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-03-31","value":318.16,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-04-30","value":324.68,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-05-28","value":296.24,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-05-31","value":296.21,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-06-30","value":297.78,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-07-30","value":261.96,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-08-31","value":300.18,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-09-30","value":349.59,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-10-29","value":427.49,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-11-30","value":404.6,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2010-12-31","value":506.97,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-01-31","value":517.49,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-02-28","value":567.69,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-03-31","value":541.83,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-04-29","value":574.72,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-05-31","value":506.78,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-06-30","value":469.21,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-07-29","value":521.53,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-08-31","value":529.83,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-09-30","value":507.55,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-10-31","value":435.8,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-11-30","value":488.27,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2011-12-30","value":480.31,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-01-31","value":462.31,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-02-29","value":465.92,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-03-30","value":490.21,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-04-30","value":484.9,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-05-31","value":480.55,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-06-29","value":393.47,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-07-31","value":438.26,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-08-31","value":410.83,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-09-28","value":375.59,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-10-31","value":319.01,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-11-30","value":315.91,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2012-12-31","value":318.33,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-01-31","value":351.63,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-02-28","value":377.62,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-03-29","value":412.7,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-04-30","value":452.87,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-05-31","value":453.45,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-06-28","value":439.18,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-07-31","value":421.47,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-08-30","value":375.51,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-09-30","value":385.31,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-10-31","value":413.41,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-11-29","value":461.28,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2013-12-31","value":455.58,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-01-31","value":448.93,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-02-28","value":455.05,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-03-31","value":476.19,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-04-30","value":488.89,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-05-30","value":467.05,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-06-30","value":478.1,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-07-31","value":488.85,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-08-29","value":534.46,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-09-30","value":629.01,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-10-31","value":618.48,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-11-28","value":699.19,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2014-12-31","value":762.46,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2015-01-30","value":815.27,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2015-02-27","value":811.23,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2015-03-31","value":842.4,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2015-04-30","value":775.2,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2015-05-29","value":807.2,"dateModification":"2015-07-31","status":"Final","valueRefId":0},{"date":"2015-06-30","value":758.21,"dateModification":"2015-07-31","status":"Final","valueRefId":0}]
Thanks in advance
Found it! Turns out my data elements did not have an id attribute, and this is somehow messing up the grid's ability to render the rows. I found a pointer to the solution in https://github.com/SitePen/dstore/blob/master/docs/Stores.md where it says:
The data should be an array of objects, and all the objects are considered to be existing objects and must have identities
After adding a unique identifier to my data, everything works ok.