SitePen / dgrid

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

DGrid 'select all' checkbox is not working as expected #1444

Closed andreayt1 closed 4 years ago

andreayt1 commented 4 years ago

Is there an ability in DGrid to select all items from the onDemandGrid grid when a 'select all' checkbox been checked. I have used below selectAll function, and it is selecting only items loaded/displayed on the grid instead of all items. Using dgrid-1.2.1 version and dojo 1.14.1

selectAll: function () { this.allSelected = true; this.selection = {}; for (var i in this._rowIdToObject) { var row = this.row(this._rowIdToObject[i]); this._select(row.id, null, true); } this._fireSelectionEvents(); }

Any suggestions would help.

webdevisme commented 4 years ago

Sounds like you need to apply the selected to the underlying dataset, not the items in the rows of the component. Can you fire a command to set them to selected within your store?

Alternative hacky way: Create another hidden DGrid sharing the same dataset, with an infinite page size. The Select All checkbox can be connected to that DGrid...

msssk commented 4 years ago

With OnDemandList or Pagination the grid often only renders a subset of rows, which means that this._rowIdToObject is not going to map every data item to a row. As mentioned, you need to store the selection state on each item in the data and add some logic that synchronizes UI select events with the data.

See also #1468