bwu-dart / bwu_datagrid

A data-grid Polymer element in Dart
MIT License
74 stars 26 forks source link

New row has to be added at the end of the data.items #36

Closed vitoulet closed 10 years ago

vitoulet commented 10 years ago

When using a DataProvider backed by a List (like MapDataItemProvider), the rendering of the grid does not reflect the data in the DataProvider.

If the new row is inserted at the beginning of the list several times, the grid will duplicate the last line (from the DataProvider) multiple times.

When I load my grid: I have one row already available: step1

I add a new row ("NEW ROW 1"): step2

I add a new row again ("NEW ROW 2"): step3

My previous "new row" got removed and the last row is duplicated.

Here is the code that I use to refresh the rendering of the grid (based on one of your examples):

  void addnewRowHandler(DataRow dataRow) {
    var item = MapDataItemAdaptor.convert(dataRow);
    grid.invalidateRow(0);
    data.items.insert(0, item);
    grid.updateRowCount();
    grid.render();
  }

Thanks! P.S. Great work by the way.

zoechi commented 10 years ago

Hi @vitoulet,

thanks for trying out bwu_datagrid and for your feedback.

Did you use a release from pub.dartlang.org or the current master branch? The branch 04_model already contains a lot of fixes which I'll merge with master soon.

I'll try it out anyway and try to make it work.

Thanks! Günter

vitoulet commented 10 years ago

Yes, I used the release from pub.dartlang.org (release 0.0.5).

I can try once the branch is merged and published on pub.dartlang.org.

Thanks. Stéphane

zoechi commented 10 years ago

I have merged the branch but I try to fix a few issues (including yours) before I publish the next release.

vitoulet commented 10 years ago

I pulled your changes and it seems to work now. I'll re-test and close the issue once it is published.

Thanks!

vitoulet commented 10 years ago

I had done a mistake in my code. I had to invalidate all the rows in order to clear the _rowCache.

  void addnewRowHandler(DataRow dataRow) {
    var item = MapDataItemAdaptor.convert(dataRow);
    grid.invalidateAllRows();
    data.items.insert(0, item);
    grid.updateRowCount();
    grid.render();
  }

I believe that it's not a big deal but it's something that could be improved.

Anyway, thanks. I am closing this issue.

zoechi commented 10 years ago

Hi Stéphane,

thanks a lot for the feedback!

Günter