I grabbed this code form some book I’ve bumped on the InternetS…
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: {
fn: function(sm,index,record) {
Ext.Msg.alert('You Selected',record.data.title);
}
}
}
});
now, sm is shorthand for selection model, we’re discussing a ExtJS GridPanel here… Everything is clear until the fn: part. AFAIK, an anonymous function is passed with 3 parameters: sm, index, and record.
Right now I’m about to get down votes for asking something extremely trivial: how do you know which parameters you should pass? If I omit index parameter, I’ll get an error… Why do I must pass 3 parameters? What’s the catch?
Consider this scenario:
Watch what happens when you skip a parameter:
The error that you seeing has nothing to do with parameter mismatch when calling a function. Javascript allows any function taking any number of parameters to be called with any number of parameters. The error is to do with trying to dereference the property
record.datawhich is not there.To answer you question, you must define the callback function using the signature specified by the API, simply for the sake of parameters being mapped correctly.