Jan 19, 2015, 4:29 PM
[CLOSED] Ext JS error - Bad Model constructor argument 2 - "session" is not a Session - dragging row onto tree
Hi,
I am dragging a row from a grid onto a tree node, and I am getting an error.
First, I've followed your example in the examples explorer
https://examples3.ext.net/#/DragDrop/Grid/Grid_to_Tree/
It works without problem. I've tried for a long time to reproduce the error in a cut down sample, but cannot seem to create the right condition.
However, I can see the code that seems to be the problem, so perhaps there is still a chance you can help.
When I drop a row onto a tree, I get the following error:
This, in turn, is called from the class
Because it is true, it creates the new Model. But notice the second parameter to the constructor:
The second parameter to the constructor has to be a session (or null). Because it is a string/id, it eventually results in that error being raised. To me this seems like a Sencha Ext JS bug? But I cannot find anything on their forums about this.
Questions:
Sorry I couldn't get a cut down sample to reproduce this... I know that is not ideal at all...
Thanks.
I am dragging a row from a grid onto a tree node, and I am getting an error.
First, I've followed your example in the examples explorer
https://examples3.ext.net/#/DragDrop/Grid/Grid_to_Tree/
It works without problem. I've tried for a long time to reproduce the error in a cut down sample, but cannot seem to create the right condition.
However, I can see the code that seems to be the problem, so perhaps there is still a chance you can help.
When I drop a row onto a tree, I get the following error:
if (session && !session.isSession) {
Ext.Error.raise('Bad Model constructor argument 2 - "session" is not a Session');
}
This is in the constructor or Ext.data.Model
This, in turn, is called from the class
Ext.tree.ViewDropZone
, method handleDropNode
, in the local function, transferData
:for (i = 0 , len = data.records.length; i < len; i++) {
record = data.records[i];
if (!record.isNode) {
if (record.isModel) {
record = new Model(record.data,record.getId()); // second parameter is invalid! It is not a session!
} else {
record = new Model(record);
}
data.records[i] = record;
}
argList[0] = record;
insertionMethod.apply(targetNode, argList);
targetView.getNavigationModel().setPosition(record);
}
In your example, isModel
is false, whereas for me it is true. I cannot see how to influence this and clearly somewhere in my real world code, which is more complex it is being set, but in any simplified version I try to create I just can't seem to get it to be false!Because it is true, it creates the new Model. But notice the second parameter to the constructor:
record.getId()
The second parameter to the constructor has to be a session (or null). Because it is a string/id, it eventually results in that error being raised. To me this seems like a Sencha Ext JS bug? But I cannot find anything on their forums about this.
Questions:
- Any idea how isModel is set to true (as I can't create a cut down example to reproduce the problem for you)
- Any idea how best to work around this: overriding transferData is not easy because it is a local function inside handleDropNode, which is a large function.
- In your example, when the row is added, it is treated like a tree node insertion. In my particular case, I want to invoke an action on the server (which is just a DirectMethod call) but I do NOT want to add the record to the tree (not visibly, anyway). Am I going to find that once the session problem is solved, this is not the right thing I am doing anyway, or this should be okay (I ask because in the debugger when I force the isModel property to false, it ends up creating a tree node to represent the record, which is what I will then need to prevent but I can't easily look into that until the initial session problem is solved first!).
Sorry I couldn't get a cut down sample to reproduce this... I know that is not ideal at all...
Thanks.
Last edited by Daniil; Jan 22, 2015 at 9:13 AM.
Reason: [CLOSED]