PDA

View Full Version : [CLOSED] Bug on plugins?



Periscope
Apr 21, 2013, 6:43 PM
I'm trying to create a plugin to encapsulate some javascript code for specific components (instead of inherit the whole component). So far, it works fine, but, when I tried to inherit from an existing plugin, MY init function is not called anymore.

Ex.:


public sealed class OrganogramNodeTreeViewDragDropPlugin : TreeViewDragDrop
{

public override string InstanceOf
{
get { return "TMC.ux.OrganogramNodeTreeViewDragDropPlugin"; }
}

}


This doesn't work (the init method of my script is never called). The DragNDrop works fine in this case.



public sealed class OrganogramNodeTreeViewDragDropPlugin : Plugin
{

public override string InstanceOf
{
get { return "TMC.ux.OrganogramNodeTreeViewDragDropPlugin"; }
}

}


This works fine (my plugin is initialized). Notice that I just changed the inheritance part. No scripts were changed.

In both cases, my script inherits from the correct base plugin:



Ext.define("TMC.ux.OrganogramNodeTreeViewDragDropPlugin",
{
extend: "Ext.tree.plugin.TreeViewDragDrop",
alias: "plugin.tmcorganogramnodetreeviewdragdrop",
treeView: null,

init: function (treeView)
{
debugger;
console.dir(arguments);
this.callParent(arguments);
this.treeView = treeView;
}
});


What I want to do is create a specific plugin that could handle some server-side code on initialization, but inheriting from an existing plugin:



public OrganogramNodeTreeViewDragDropPlugin()
{
AllowLeafDrop = true;
AppendOnly = true;
DDGroup = "OrganogramNodesEditor";
DragGroup = "OrganogramNodesEditor";
DropGroup = "OrganogramNodesEditor";
NodeHighlightOnDrop = true;
NodeHighlightOnRepair = true;
}


But I can't, because server side plugins works, but doesn't trigger the init method of MY script when inheriting anything but Plugin class =\

Daniil
Apr 22, 2013, 6:43 AM
Hi @Periscope,

It appears to be working for me. Here is a test case. Could you provide your test case?

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
public sealed class TestPlugin : Plugin
{
public override string InstanceOf
{
get { return "Ext.tree.plugin.TestPlugin"; }
}
}

protected void Page_Load(object sender, EventArgs e)
{
this.TreeView1.Plugins.Add(new TestPlugin());
}

</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
Ext.define("Ext.tree.plugin.TestPlugin", {
extend: "Ext.tree.plugin.TreeViewDragDrop",
alias: "plugin.testplugin",

init: function () {
alert("I am within the init function")
this.callParent(arguments);
}
});
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:TreePanel runat="server">
<Root>
<ext:Node Text="Root (level 0)" Expanded="true">
<Children>
<ext:Node Text="Node1 (level 1)" Expanded="true">
<Children>
<ext:Node Text="Node1 (level 2)" Leaf="true" />
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
<View>
<ext:TreeView ID="TreeView1" runat="server" />
</View>
</ext:TreePanel>
</form>
</body>
</html>



By the way, you might need to override a Plugin's PType property as well.

Periscope
Apr 22, 2013, 3:03 PM
My test case is the same of yours, just change the following line and the alert isn't displayed anymore:



public sealed class TestPlugin : Ext.Net.TreeViewDragDrop

Daniil
Apr 22, 2013, 6:03 PM
Well, as I said, you should override the PType property as well.

Example

public sealed class TestPlugin : Ext.Net.TreeViewDragDrop
{
public override string InstanceOf
{
get { return "Ext.tree.plugin.TestPlugin"; }
}

public override string PType
{
get
{
return "testplugin";
}
}
}