PDA

View Full Version : [OPEN] [#451] How to deal with Ext.Action ?



alex303
Mar 12, 2014, 9:14 AM
Hello, take a look at that example http://docs.sencha.com/extjs/4.2.1/#!/example/menu/action-grid.html
I want to implement same logic: fill contextmenu and toolbar from single action instance (Ext.Action). Can you provide simple example how to do it? How to create Ext.Action within Ext.Net and how to initialize menu/toolbar items by those actons?

Vladimir
Mar 12, 2014, 9:58 AM
Ext.Net doesn't support Ext.Action

alex303
Mar 12, 2014, 10:03 AM
Ext.Net doesn't support Ext.Action
Very pity. Is there any plans to implement this mechanism in the future?

Daniil
Mar 12, 2014, 11:36 AM
Just to clarify, it is still possible to use with Ext.NET, in JavaScript.

Example

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

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

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test1", "test" },
new object[] { "test2", "test" },
new object[] { "test3", "test" }
};
}
}
</script>

<!DOCTYPE html>

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

<script>
var action1 = Ext.create('Ext.Action', {
iconCls: '#Add',
text: 'Action 1',
disabled: true,
handler: function (widget, event) {
var rec = App.GridPanel1.getSelectionModel().getSelection()[0];

if (rec) {
Ext.Msg.info('Option 1', 'Do Option 1 with ' + rec.get('test1'));
}
}
});

var action2 = Ext.create('Ext.Action', {
iconCls: '#Delete',
text: 'Action 2',
disabled: true,
handler: function (widget, event) {
var rec = App.GridPanel1.getSelectionModel().getSelection()[0];

if (rec) {
Ext.Msg.info('Option 2', 'Do Option 2 with ' + rec.get('test1'));
}
}
});
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server">
<Bin>
<ext:Menu ID="Menu1" runat="server">
<Listeners>
<BeforeRender Handler="this.add([action1, action2]);" />
</Listeners>
</ext:Menu>
</Bin>
<TopBar>
<ext:Toolbar runat="server">
<Listeners>
<BeforeRender Handler="this.add([action1, action2]);" />
</Listeners>
</ext:Toolbar>
</TopBar>
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test 1" DataIndex="test1" />
<ext:Column runat="server" Text="Test 2" DataIndex="test2" />
</Columns>
</ColumnModel>
<ViewConfig>
<Listeners>
<ItemContextMenu Handler="e.stopEvent();
App.Menu1.showAt(e.getXY());
return false;" />

</Listeners>
</ViewConfig>
<SelectionModel>
<ext:RowSelectionModel runat="server">
<Listeners>
<SelectionChange Handler="if (selected.length) {
action1.enable();
action2.enable();
} else {
action1.disable();
action2.disable();
}" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</form>
</body>
</html>

alex303
Mar 12, 2014, 3:08 PM
Just to clarify, it is still possible to use with Ext.NET, in JavaScript.

Daniil, thanks... but I'm not sure this is good way for me... I need to generate Ext.Action dynamically from codebehind, so I need component model to describe Ext.Action and generate it in javascript.

Daniil
Mar 13, 2014, 4:40 AM
Created a feature ticket:
https://github.com/extnet/Ext.NET/issues/451

Though, no promise.