-
Bug
-
Resolution: Fixed
-
Normal
-
8.0.4.2
-
Security Level: Jimmy
-
None
-
IE11
-
None
Steps to Reproduce
Run the fiddle:
http://zkfiddle.org/sample/32u4u8q/3-checkable-wrong-rendering#source-1
Click the "select all" checkbox
Scroll down to row 20
Current Result
A JS exception is thrown in the console
zul.sel.wpd:1022 Uncaught TypeError: Cannot read property '$n' of undefined
at init.fireOnSelect (zul.sel.wpd:1022)
at init._zkf (zul.sel.wpd:951)
at init._doClick (zul.sel.wpd:2531)
at HTMLSpanElement.<anonymous> (zk.wpd:15037)
at HTMLSpanElement.dispatch (zk.wpd:5157)
at HTMLSpanElement.elemData.handle (zk.wpd:4828)
Selectable items not yet rendered are not selected
Expected Result
no exception
select all should select items
Debug Info
Does not happen with EE ROD (only happen with CE ROD - live data)
Root Cause
If no selectable items are currently rendered, this.getSelectedItem() will return a null value in zul.sel.Listbox.selectAll when passing it as ref to fireOnSelect(ref, evt)
during fireOnSelect, cm = ref.$n('cm') is called to find the checkmark of this non-existent
Workaround
<script><![CDATA[ zk.afterLoad('zul.sel', function() { var xListbox = {}; zk.override(zul.sel.Listbox.prototype, xListbox ,{ selectAll : function (notify, evt) { for (var it = this.getBodyWidgetIterator(), w; (w = it.next());) if (w._loaded && !w.isDisabled() && w.isSelectable()) this._changeSelect(w, true); if(!this.getSelectedItem()) this._shallSyncCM = false; if (notify && evt !== true && this.getSelectedItem()) this.fireOnSelect(this.getSelectedItem(), evt); } });//zk.override });//zk.afterLoad ]]></script>