Nextmatch onselect attribute understands app.appname.function directly, and passes nextmatch reference & list of ids

This commit is contained in:
Nathan Gray 2013-04-12 10:33:29 +00:00
parent 8d339ace5e
commit b994f33825
2 changed files with 25 additions and 6 deletions

View File

@ -392,7 +392,20 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
return {ids:[],inverted:false}; return {ids:[],inverted:false};
}, },
onselect: function() { /**
* Event handler for when the selection changes
*
* If the onselect attribute was set to a string with javascript code, it will
* be executed "legacy style". You can get the selected values with getSelection().
* If the onselect attribute is in app.appname.function style, it will be called
* with the nextmatch and an array of selected row IDs.
*
* The array can be empty, if user cleared the selection.
*
* @param action ActionObject From action system. Ignored.
* @param senders ActionObjectImplemetation From action system. Ignored.
*/
onselect: function(action,senders) {
// Execute the JS code connected to the event handler // Execute the JS code connected to the event handler
if (this.options.onselect) if (this.options.onselect)
{ {
@ -403,12 +416,14 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
if(parts.length == 3 && typeof window.app[parts[1]] == "object" && if(parts.length == 3 && typeof window.app[parts[1]] == "object" &&
typeof window.app[parts[1]][parts[2]] == "function") typeof window.app[parts[1]][parts[2]] == "function")
{ {
window.app[parts[1]][parts[2]].call(this, this.getSelection()); // Call as Action callback
//window.app[parts[1]][parts[2]].apply( window.app[parts[1]], arguments);
window.app[parts[1]][parts[2]].apply( window.app[parts[1]], [this,this.getSelection().ids]);
} }
} }
// Exectute the legacy JS code // Exectute the legacy JS code
else if (!(et2_compileLegacyJS(this.options.onselect, this, _node))()) else if (!(et2_compileLegacyJS(this.options.onselect, this, this.div))())
{ {
return false; return false;
} }

View File

@ -64,7 +64,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
} }
// Add our selection callback to selection manager // Add our selection callback to selection manager
var self = this; var self = this;
this._objectManager.setSelectedCallback = function() {self._selectCallback(this);}; this._objectManager.setSelectedCallback = function() {self._selectCallback.apply(self,[this,arguments]);};
// Call the parent et2_dataview_controller constructor // Call the parent et2_dataview_controller constructor
this._super(_parentController, _grid, this, this._rowCallback, this._super(_parentController, _grid, this, this._rowCallback,
@ -264,9 +264,13 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
/** /**
* Execute the select callback when the row selection changes * Execute the select callback when the row selection changes
*/ */
_selectCallback: function(action) _selectCallback: function(action,senders)
{ {
this._widget.onselect.call(this._widget, action); if(typeof senders == "undefined")
{
senders = [];
}
this._widget.onselect.call(this._widget, action,senders);
}, },
/** -- Implementation of et2_IDataProvider -- **/ /** -- Implementation of et2_IDataProvider -- **/