Rename DataView's `getItem()` to `getRow()`
See original GitHub issueIssue Description
It’s a bit confusing that getItem()
appears to operate on the same data set as setItems()
addItem()
, updateItem()
and deleteItem()
, which it actually does not. Especially confusing that there is a getItems()
that does operate on the same data set.
In fact, getItem()
retrieves a “row” which does not even exist until a refresh()
has been processed (or actually recalc()
). And if called between abeginUpdate()
//endUpdate()
pair, this is not done synchronously.
For example, at first glance, this code might seem to be good:
view.beginUpdate();
view.addItem(theItem);
var firstItem = view.getItem(0);
But as you all know, the getItem()
will fail. (assuming an empty view)
Suggest to rename getItem()
to getRow()
.
I realize this rename could also mean that other (public) methods should be renamed, ones that operate on the same data set (i.e. the rows
member variable)`.
I know this is a breaking change. Deprecation is of course advised. At first merely in the documentation and later even a console.warn()
could be added to the old method.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
While deprecation is an option, it’s still disruptive in the end. What I tend to prefer is to release a new breaking version and then have an additional package to make it backwards compatible by overriding new features or mapping the old names to the new, like how
jQuery-migrate
worked in the old days. That said, it’s hard to gauge how popular Slickgrid is, and therefore what impact breaking changes would have.I have a private branch which may be able to feed back significant changes and improvements, but it’s too early to tell yet how many resources I’m going to be able to devote to that - it’s part of another project.
👍