jQWidgets Forums
jQuery UI Widgets › Forums › Plugins › Data Adapter › Bug with dataadapter when used in virtual mode grid
Tagged: dataadapter
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 11 months ago.
-
Author
-
Hello,
I’d like to report a bug when using a dataAdapter (json data) for a grid’s source, and the grid is in virtual mode, with autoheight false.
Here’s the behaviour:
Parameters:
Grid page size: 500
Grid autoHeight: false
Grid height: 100% of container
Using jqxVersion: v2.9.0Test cases:
Server returns 500 results.
dataAdapter.records.length: 500 (correct)Server returns 8 results.
dataAdapter.records.length: 30 (varies, according to the height of the grid container. It’s roughly double the rows it could contain.)
Examining the dataAdapter.records shows that the first 8 contain indeed the proper data, while the rest contain the structure, but not any data -eg: firstName: “”, lastName: “” etc)As a workaround for anyone experiencing this, I suggest using the dataAdapter.originaldata property to get the “correct” results and length.
Hi,
I am sorry, but that is not a bug according to us. When the Grid is in virtual mode, the dataAdapter is filled with data on demand and is updated on demand depending on the requested Rows by the Grid. In addition, the “length” field should not be considered to be equal to the numbers of records in a JavaScript Array object, because it is not.
Take a look at the following code as an example:
var records = new Array(); records[30] = "Data"; alert(records.length);
The result of the length is 31 and as you can see the Array is with 1 record.
The sample is with the Grid, it requests records for the view which could be from 11 to 20 and the Array will have 10 items, but the length will return 21.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI mention it as a not-expected behaviour. If I want to re-use the records in other parts of my code, my first thought would be to use the dataadapters.records property, not its originaldata, nor the grids ‘getrows’ method.
As for the sample: The length is 31, because you manually declared the 31th position of the array (leaving all others empty).
If your code was instead:var records = [];records.push("Data");alert(records.length);
the length would be properly 1.
Hi,
I am sorry that you find it to be unexpected, but that is how it should work by design. The Grid does not expect an array in virtual mode with indexes that start from 0 and you should not expect that the Array’s length will be equal to the numbers of records and I explained you why. For using the widget in Virtual Mode you may look at the available working samples.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.