[OPEN] [#451] How to deal with Ext.Action ?

  1. #1

    [OPEN] [#451] How to deal with Ext.Action ?

    Hello, take a look at that example http://docs.sencha.com/extjs/4.2.1/#...tion-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?
    Last edited by Daniil; Mar 13, 2014 at 4:40 AM. Reason: [OPEN] [#451]
  2. #2
    Ext.Net doesn't support Ext.Action
  3. #3
    Quote Originally Posted by Vladimir View Post
    Ext.Net doesn't support Ext.Action
    Very pity. Is there any plans to implement this mechanism in the future?
  4. #4
    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>
  5. #5
    Quote Originally Posted by Daniil View Post
    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.
  6. #6
    Created a feature ticket:
    https://github.com/extnet/Ext.NET/issues/451

    Though, no promise.

Similar Threads

  1. Replies: 1
    Last Post: Apr 23, 2012, 3:09 PM
  2. Replies: 2
    Last Post: Oct 25, 2011, 11:10 AM
  3. Replies: 4
    Last Post: Jan 17, 2011, 3:35 PM
  4. As a record deal ext:GridPanel?
    By Dig2010 in forum 1.x Help
    Replies: 2
    Last Post: Dec 01, 2010, 7:49 PM
  5. [CLOSED] How to deal with a null date in a JSON Web Service?
    By dev in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 31, 2010, 11:51 PM

Posting Permissions