View Full Version : [FIXED] binding grid selection - what if I deselectAll() ?

24 Sep 2014, 1:49 PM
I don't know if this is a bug or how should I handle this properly.


- a grid with a ViewModel
- a form sharing the same ViewModel
- form title & fields are bound to grid.selection

Everything works fine while selecting rows in the grid.

The issue appears when user deselects all rows in the grid (click bellow the last grid row)
The form still has the last values but there's NO selected record in the grid !

Same thing with the title bind. How can I reset the title if no rows are selected (using bind) ?

If after you deselected all rows, edit any of the fields, select back rows, when deselecting again the previously edited field seems to be emty now (no matter what was the value after edit)....

PS: I use this with two grids / stores associated (parent / child), but the same thing happens: child store remains filtered on the last selected parent record after deselectAll().


1 Oct 2014, 9:08 AM
nothing on this one ?

if I use selectionchange event on the grid and check if nothing is selected how can I empty child grid with it's filtered data ?

If I do childStore.removeAll() while using session, I will not see those anymore...

1 Oct 2014, 1:11 PM

Thank you for an excellent test case. This seems like it would be a fairly common use case, so we're discussing this internally. Apparently, the bind doesn't attempt to evaluate on the deselection because the "chain" is broken. That process is currently required for digesting async data.

Until we figure out how to proceed, you could do something along these lines:


1 Oct 2014, 1:46 PM
Thanks Greg,

Nice (working) solution for form case.
But as stated, my first BUMP on this is two grids (parent - child records).

There I cannot do anything (as I've tried):

- if I specify childGrid.getStore().removeAll() - to remove the filtered records of the child grid, then I will never see those records when reselecting that parent record....I'm using a data.session()
- same thing hapened if I've added manually a filter on child store on some unexisting ID (like 0)
- tried also setBind({store:null}), but this breaks the initial bound, so I have to manually readd it on businessLogic in case if...

Tried even a not so clever solution: grid.removeAll() which does something else, and which by the way I think has another bug, it raises an error:

Uncaught TypeError: Cannot read property 'getScrollLeft' of null

Check this fiddle fork (press grid tbar button with JS console open): https://fiddle.sencha.com/#fiddle/b78

20 Nov 2014, 11:19 PM
It's true, feature with reset of selection and form on deselection via binding is really required in every day work.But I've found a simple decision. To create formula with bind on selection record, and to return non-existing id in get() function if there is no selected record.

formulas: {
parent_id: {
bind: '{parent.selection}',
get: function(record) {
return record ? record.get('id') : -1;

7 Feb 2015, 3:07 AM
Hi ka-reon,

Seems interesting, but haven't figured it out how / would you use it ...
Can you enlighten me on my example / fiddle ?

Couldn't figure it our myself :(
At least for my scenario: two grids (one filtered by parent's selection)....

Actually the formula works when bind to parent.selection (it outputs the correct values, and -1 when deselected parent rows), but don't know how to use it to filter the child grid....

As on the chid grid I have store bind '{parent.selection.childStore}' but it doesn't uses my formula though....
I suppose I'll have to manually use child store filter based on formula result....I'll try that !

Thanks !

7 Feb 2015, 6:25 PM
This is fixed in 5.1.0, when the parent is nulled out (the selection) it cascades down to any children for them to reevaluate.