[CLOSED] 2 different items created with directmethod / data exchange trouble

  1. #1

    [CLOSED] 2 different items created with directmethod / data exchange trouble

    Hello

    Szenario:
    I have two items which are created via DirectMethod in code behind (not at the same time and not at page start): a gridpanel with a store and a popup window, that should check something in the gridpanel store before submitting its data. Vaguely I can remember that it is not possible to get the gridpanel store with #{STORE}.doSomething() from the popup window via javascript (some registering problem) but I am not sure anymore and I haven't found anything related yet.

    Question:
    How is it possible to do what I would like to without doing an extra loop to the server?

    Thank you very much for any hint in the right direction.

    best regards!
    Last edited by fabricio.murta; Aug 06, 2015 at 11:02 AM. Reason: [CLOSED]
  2. #2
    Hello @tMp!

    I believe you can get the freshly created gridPanel or store with Ext.getCmp(id). Ensure you have the correct ID and the ID is unique in the whole page (you can use dynamic ID and get it as soon as it is created).

    About the single round-trip, well, if I understand correctly, you are on this situation:
    Possible actual scenario 1 - PAS1
    1. Direct Method returns a GridPanel with a filled store (1 server side call)
    2. As a callback, right when the direct method above returns, you call a method on the generated store to check something.
    3. If that something is true, then you call another direct method for the pop up (2 server side call)

    But, as you said you don't remember if you can get the store after it is returned by direct method, probably you get that condition check from somewhere not in the grid panel, and present before the grid is created by the direct method call. For this:
    Possible actual scenario 2 - PAS2
    1. Direct Method returns a GridPanel witha filled store (1 server side call)
    2. As a callback, right when the direct method above returns, you check the condition on somewhere else you already had access to before step 1
    3. If that candition is true, then you call another direct method for the pop up (2 server seide calls)

    Now for the alternate approaches to use a single round-trip:
    PAS1 - 1 cycle
    1. The Direct method, before returning the grid, checks its contents in code behind still for the condition. If the condition is true, returns also the script to create the pop up

    PAS2 - 1 cycle
    1. Before calling the direct method, check the condition and pass it as a parameter during the direct call
    2. On the direct method call, if the provided condition is true, call the code-behind method that would issue the script to create the pop up window right after the gridpanel code.

    Well, I hope I could figure your scenario correctly and provided some useful information here! :)
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hi,

    sorry, I was to much in a hurry when I wrote my question. Let me explain it a little bit more:

    The grid resides in a tabpanel that is created dynamically via directmethod when the gridpanel is activated. The grid has a toolbar with an add new record button. That button generates a popup window via directmethod with a single dropdown box. Now I would like to check if the from the user selected dropdown entry has already a key in the gridpanel store to tell him that duplicate entries are not allowed. If I don't do that the database behind will throw the error duplicate key insertion not allowed...

    I am not sure if your Scenarios are valid on this one? I will try to make a demo as soon as i have so spare time.

    thanks you very much.
  4. #4
    Well, you can do that during the code behind you run to update the database. Before running the sql query (I suppose you doing this way), make a select to check for duplicity. If there's a duplicity, instead of running the sql insert, you return a script changing (for example) an originally empty, red label on the pop-up window complaining about the duplicate.

    If you cache the test on the page you increase the risk of having two concurrent users adding the same record on the database.

    Better than that above, you can just handle the sql error (or make a sql procedure) so that you guarantee a single transaction is made between the check-for-duplicate and insert.

    Does that sound good?
    Fabrício Murta
    Developer & Support Expert
  5. #5
    hello again,

    yes I will have to do it like that anyway... just that I a very curious, if it is possible to get to the gridpanel store via javascript without doing the return. You are avoiding this question completely ;) Don't get me wrong, your suggestion are all valid and I will follow them, I would just love to know: is the other way even possible or not?

    thanks a lot and best regards!
  6. #6
    Oh yes, sorry... Honestly, I didn't try to avert your question about traversing a store... I really just thought it was not worth as you'd be just falling to a deep concurrency trap.

    So, how would you check the store for an duplicate, javascript-side?

    This is how you do it:
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.haystack.DataSource = this.Data;
                this.haystack.DataBind();
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                    new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am" },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am" },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, "9/1 12:00am" },
                    new object[] { "General Electric Company", 34.14, -0.08, -0.23, "9/1 12:00am" },
                    new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, "9/1 12:00am" },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, "9/1 12:00am" },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, 0.13, "9/1 12:00am" },
                    new object[] { "Intel Corporation", 19.88, 0.31, 1.58, "9/1 12:00am" },
                    new object[] { "International Business Machines", 81.41, 0.44, 0.54, "9/1 12:00am" },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, 0.09, "9/1 12:00am" },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, 0.15, "9/1 12:00am" },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, 2.40, "9/1 12:00am" },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, 1.01, "9/1 12:00am" },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, 0.54, "9/1 12:00am" },
                    new object[] { "Pfizer Inc", 27.96, 0.4, 1.45, "9/1 12:00am" },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, 0.58, "9/1 12:00am" },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, 1.02, "9/1 12:00am" },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, 0.88, "9/1 12:00am" },
                    new object[] { "Verizon Communications", 35.57, 0.39, 1.11, "9/1 12:00am" },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am" }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Simple Array Grid - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />    
    
        <style>
            .x-grid-row-over .x-grid-cell-inner {
                font-weight : bold;
            }
        </style>
    
        <script>
            var template = '<span style="color:{0};">{1}</span>';
    
            var change = function (value) {
                return Ext.String.format(template, (value > 0) ? "green" : "red", value);
            };
    
            var pctChange = function (value) {
                return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
            };
    
            var checkEntryExists = function () {
                var lineMatching = App.haystack.findExact('company', App.needle.value);
                if (lineMatching >= 0) {
                    App.resultPlaceHolder.setText("Found on the above grid!!! Found on line " + (lineMatching + 1))
                } else {
                    App.resultPlaceHolder.setText("Not found on the above grid.")
                }
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <h1>Simple Array Grid</h1>
        
        <ext:GridPanel 
            ID="GridPanel1"
            runat="server" 
            Title="Array Grid" 
            Width="600" 
            Height="350">
            <Store>
                <ext:Store ID="haystack" runat="server">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="company" />
                                <ext:ModelField Name="price" Type="Float" />
                                <ext:ModelField Name="change" Type="Float" />
                                <ext:ModelField Name="pctChange" Type="Float" />
                                <ext:ModelField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" />
                    <ext:Column runat="server" Text="Price" DataIndex="price">                  
                        <Renderer Format="UsMoney" />
                    </ext:Column>
                    <ext:Column runat="server" Text="Change" DataIndex="change">
                        <Renderer Fn="change" />
                    </ext:Column>
                    <ext:Column runat="server" Text="Change" DataIndex="pctChange">
                        <Renderer Fn="pctChange" />
                    </ext:Column>
                    <ext:DateColumn runat="server" Text="Last Updated" DataIndex="lastChange" />
                </Columns>            
            </ColumnModel>       
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Print" Icon="Printer" Handler="this.up('grid').print();" />
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:GridPanel>
        <ext:Label runat="server" Text="Type a text here to see if there's a matching company name in the grid above." />
        <ext:TextField runat="server" ID="needle" Width="500" EmptyText="Enter your text here">
            <Listeners>
                <Change Fn="checkEntryExists" />
            </Listeners>
        </ext:TextField>
        <ext:Label runat="server" Text="Result:&nbsp;" />
        <ext:Label runat="server" ID="resultPlaceHolder" Text="Not on the above grid." StyleSpec="font-weight: bold" />
    </body>
    </html>
    I parted from this example and just added the text search field + function, nothing too fancy so you can understand the logic here. Basically, you have the store's find(), findExact() methods to search within a store's column. You can also use findRecord() to match exact records to the letter.

    Sorry to leave the impression that I didn't want to explain you how to search in a store's records. I hope this sample is good enough as a proper apology.
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Hello Fabricio

    really no worries! everything is alright....

    I took your example and modified it to show you want I really wanted to do :)

    1) Click on Fill Gridpanel
    2) You don't have to fill in anything, just click "add)
    3) you see a simple alert-Window. I would love to get something like #{store}.getCount() there. I know it is not the original question but the principle still is. If I can get the count I can find the record... but I can't get hold of that store via javascript. And that is why I wanted to ask, if that is even possible?

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                    new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am" },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am" },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, "9/1 12:00am" },
                    new object[] { "General Electric Company", 34.14, -0.08, -0.23, "9/1 12:00am" },
                    new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, "9/1 12:00am" },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, "9/1 12:00am" },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, 0.13, "9/1 12:00am" },
                    new object[] { "Intel Corporation", 19.88, 0.31, 1.58, "9/1 12:00am" },
                    new object[] { "International Business Machines", 81.41, 0.44, 0.54, "9/1 12:00am" },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, 0.09, "9/1 12:00am" },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, 0.15, "9/1 12:00am" },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, 2.40, "9/1 12:00am" },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, 1.01, "9/1 12:00am" },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, 0.54, "9/1 12:00am" },
                    new object[] { "Pfizer Inc", 27.96, 0.4, 1.45, "9/1 12:00am" },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, 0.58, "9/1 12:00am" },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, 1.02, "9/1 12:00am" },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, 0.88, "9/1 12:00am" },
                    new object[] { "Verizon Communications", 35.57, 0.39, 1.11, "9/1 12:00am" },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am" }
                };
            }
        }
    
        [DirectMethod]
        public void OnFillGrid()
        {
            Ext.Net.Panel pnl = X.GetCmp<Ext.Net.Panel>("emptyPanel");
    
            // create toolbar with add group button
            Toolbar tb = new Toolbar
            {
                Items =
                {
                    new Ext.Net.Button { Text = "Add", Icon = Icon.Add, Listeners = { Click = { Handler = "App.direct.OnPopUpWindow();" }}},
                }
            };
    
            pnl.Items.Add(tb);
    
            GridPanel gp = new GridPanel
            {
                Store = {
                    new Store {
                        ID = "store",
                        Model =
                        {
                            new Model {
                                Fields =
                                {
                                    new ModelField { Name = "company", Type = ModelFieldType.Auto }
                                }
                            }
                        },
                        DataSource = Data
                    }
                },
                ColumnModel =
                {
                    Columns =
                    {
                        new Column { Text = "Company", DataIndex = "company" }
                    }
                }
            };
    
            pnl.Items.Add(gp);
            pnl.UpdateContent();
        }
    
        [DirectMethod]
        public void OnPopUpWindow()
        {
            Window win = new Window
            {
                ID = "win",
                Width = 400,
                Y = 150,
                Modal = true,
                Closable = false,
                Items =
                {
                    new FormPanel
                    {
                        ID = "frmPanel",
                        Border = false,
                        ButtonAlign = Alignment.Right,
                        BodyPadding = 5,
                        Layout = "VBoxLayout",
                        LayoutConfig = { new VBoxLayoutConfig { Align = VBoxAlign.Stretch } },
                        Items =
                        {
                            new TextField
                            {
                                ID = "txtField",
                                        FieldLabel = "Company",
                                        LabelWidth = 90,
                                        Flex = 1,
                                        AutoFocus = true
                            },
                        },
                        Buttons =
                        {
                            new Ext.Net.Button
                            {
                                ID = "btnCheck",
                                Text = "add",
                                Width = 100,
                                OnClientClick = "alert('test');"
                            },
                            new Ext.Net.Button
                            {
                                Text = "cancel",
                                Width = 100,
                                Listeners =  { Click = { Handler = "#{frmPanel}.reset(); #{win}.close();" } }
                            }
                        }
                    }
                }
            };
            win.Render(this.Form);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Simple Array Grid - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />    
    
        <script>
            var checkEntryExists = function () {
                var lineMatching = App.haystack.findExact('company', App.needle.value);
                if (lineMatching >= 0) {
                    App.resultPlaceHolder.setText("Found on the above grid!!! Found on line " + (lineMatching + 1))
                } else {
                    App.resultPlaceHolder.setText("Not found on the above grid.")
                }
            };
        </script>
    </head>
    <body>
        
        <form id="form" runat="server">
        <ext:ResourceManager runat="server" />
        
        <ext:Button runat="server" Text="FillGridPanel" OnClientClick="App.direct.OnFillGrid();"></ext:Button>
    
        <ext:Panel ID="emptyPanel" runat="server" Title="Empty panel for grid"></ext:Panel>
        
            </form>
    </body>
    </html>
    Thanks for everything. And really - no worries - it never occured me to think you really didn't want to answer ;) I like how you try to look at the questions from every angle.

    cheers!

    PS: I know what you see in the test doesn't make any sense but I tried to get the principle of my app down to the bare minimum....
  8. #8
    Hello @tMp!

    Use App.store.getCount(). There are also other options like App.store.getTotalCount(). Have a look at their descriptions (linked on them) to decide which one works best for you.

    To illustrate the use of it:
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                    new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am" },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am" },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, "9/1 12:00am" },
                    new object[] { "General Electric Company", 34.14, -0.08, -0.23, "9/1 12:00am" },
                    new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, "9/1 12:00am" },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, "9/1 12:00am" },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, 0.13, "9/1 12:00am" },
                    new object[] { "Intel Corporation", 19.88, 0.31, 1.58, "9/1 12:00am" },
                    new object[] { "International Business Machines", 81.41, 0.44, 0.54, "9/1 12:00am" },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, 0.09, "9/1 12:00am" },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, 0.15, "9/1 12:00am" },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, 2.40, "9/1 12:00am" },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, 1.01, "9/1 12:00am" },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, 0.54, "9/1 12:00am" },
                    new object[] { "Pfizer Inc", 27.96, 0.4, 1.45, "9/1 12:00am" },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, 0.58, "9/1 12:00am" },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, 1.02, "9/1 12:00am" },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, 0.88, "9/1 12:00am" },
                    new object[] { "Verizon Communications", 35.57, 0.39, 1.11, "9/1 12:00am" },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, "9/1 12:00am" }
                };
            }
        }
    
        [DirectMethod]
        public void OnFillGrid()
        {
            Ext.Net.Panel pnl = X.GetCmp<Ext.Net.Panel>("emptyPanel");
    
            // create toolbar with add group button
            Toolbar tb = new Toolbar
            {
                Items =
                {
                    new Ext.Net.Button { Text = "Add", Icon = Icon.Add, Listeners = { Click = { Handler = "App.direct.OnPopUpWindow(App.store.getCount());" }}},
                }
            };
    
            pnl.Items.Add(tb);
    
            GridPanel gp = new GridPanel
            {
                Store = {
                    new Store {
                        ID = "store",
                        Model =
                        {
                            new Model {
                                Fields =
                                {
                                    new ModelField { Name = "company", Type = ModelFieldType.Auto }
                                }
                            }
                        },
                        DataSource = Data
                    }
                },
                ColumnModel =
                {
                    Columns =
                    {
                        new Column { Text = "Company", DataIndex = "company" }
                    }
                }
            };
    
            pnl.Items.Add(gp);
            pnl.UpdateContent();
        }
    
        [DirectMethod]
        public void OnPopUpWindow(int curCount = 0)
        {
            Window win = new Window
            {
                ID = "win",
                Width = 400,
                Y = 150,
                Modal = true,
                Closable = false,
                Items =
                {
                    new FormPanel
                    {
                        ID = "frmPanel",
                        Border = false,
                        ButtonAlign = Alignment.Right,
                        BodyPadding = 5,
                        Layout = "VBoxLayout",
                        LayoutConfig = { new VBoxLayoutConfig { Align = VBoxAlign.Stretch } },
                        Items =
                        {
                            new TextField
                            {
                                ID = "txtField",
                                        FieldLabel = "Company",
                                        LabelWidth = 90,
                                        Flex = 1,
                                        AutoFocus = true
                            },
                            new Ext.Net.Label
                            {
                                Text = "Current entry count: " + curCount
                            }
                        },
                        Buttons =
                        {
                            new Ext.Net.Button
                            {
                                ID = "btnCheck",
                                Text = "add",
                                Width = 100,
                                OnClientClick = "alert('test');"
                            },
                            new Ext.Net.Button
                            {
                                Text = "cancel",
                                Width = 100,
                                Listeners =  { Click = { Handler = "#{frmPanel}.reset(); #{win}.close();" } }
                            }
                        }
                    }
                }
            };
            win.Render(this.Form);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Simple Array Grid - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />    
    
        <script>
            var checkEntryExists = function () {
                var lineMatching = App.haystack.findExact('company', App.needle.value);
                if (lineMatching >= 0) {
                    App.resultPlaceHolder.setText("Found on the above grid!!! Found on line " + (lineMatching + 1))
                } else {
                    App.resultPlaceHolder.setText("Not found on the above grid.")
                }
            };
        </script>
    </head>
    <body>
        
        <form id="form" runat="server">
        <ext:ResourceManager runat="server" ScriptMode="Debug" SourceFormatting="true" />
        
        <ext:Button runat="server" Text="FillGridPanel" OnClientClick="App.direct.OnFillGrid();"></ext:Button>
    
        <ext:Panel ID="emptyPanel" runat="server" Title="Empty panel for grid"></ext:Panel>
        
            </form>
    </body>
    </html>
    Notice I didn't try to get it from inside the directMethod: you created the store dynamically, so, according to the Asp.NET page life cycle limitations (not an Ext.NET or ExtJS limitation), you will not be able to access it from code behind. Usually you can't access javascript-bound variables from code behind during AJAX calls (direct events/methods), specially when they are dynamically created. The solution for this is transmit the necessary data to the AJAX method.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  9. #9
    Pefect! :) Thank you very much!

    PS: and sorry for the troubles...
  10. #10
    No problem, glad we were able to help you out!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] send store data items to directmethod
    By snow_cap in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 29, 2013, 10:07 PM
  2. [CLOSED] Static DirectMethod and Dynamic Window (created from code behind)
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 16, 2012, 1:01 PM
  3. [CLOSED] DirectMethod missing when control created dynamically
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 08, 2012, 8:29 PM
  4. [CLOSED] Trouble to add new data to a GridPanel
    By csssi_coolite in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 21, 2010, 10:04 AM
  5. [CLOSED] [1.0] Tabstrip with dynamicly created items - items.count always 0
    By klaus.schwarz in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 07, 2010, 11:40 AM

Posting Permissions