[CLOSED] Get Item from Store

  1. #1

    [CLOSED] Get Item from Store

    Last edited by Daniil; Oct 03, 2013 at 5:07 PM. Reason: [CLOSED]
  2. #2
    Hi @osef,

    A selected item is submitted automatically if there is a <form runat="server"> on the page. So, you can get it this way:
    this.MultiSelectID.SelectedItem.Value
    As for the first item. It is not submitted. You can retrieve it on client side and send as an extra parameter of a request.
    App.MultiSelectId.getStore().getAt(0).data[App.MultiSelectId.valueField]
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @osef,

    A selected item is submitted automatically if there is a <form runat="server"> on the page. So, you can get it this way:
    this.MultiSelectID.SelectedItem.Value
    As for the first item. It is not submitted. You can retrieve it on client side and send as an extra parameter of a request.
    App.MultiSelectId.getStore().getAt(0).data[App.MultiSelectId.valueField]
    Hi Daniil, thank you, but, How Can I to get the full object("Art") from of Store?

    Exameple: Art objArt = (Art)StoreID...;

    My Store is DataBind with a List<Art>.

    Regards
  4. #4
    You can submit a Store's data.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public class Test
        {
            public string Value { get; set; }
            public string Text { get; set; }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.MultiSelect1.GetStore();
                store.DataSource = new object[] 
                { 
                    new Test()
                    {
                        Value = "1",
                        Text = "Item 1"   
                    },
                    new Test()
                    {
                        Value = "2",
                        Text = "Item 2"   
                    },
                    new Test()
                    {
                        Value = "3",
                        Text = "Item 3"   
                    }
                };
            }
        }
    
        protected void Submit(object sender, DirectEventArgs e)
        {
            List<Test> tests = JSON.Deserialize<List<Test>>(e.ExtraParams["data"]);
    
            X.Msg.Alert("Submit", tests.Count).Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:MultiSelect 
                ID="MultiSelect1" 
                runat="server"
                ValueField="Value"
                DisplayField="Text">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="Value" />
                                    <ext:ModelField Name="Text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
            </ext:MultiSelect>
    
            <ext:Button runat="server" Text="Submit">
                <DirectEvents>
                    <Click OnEvent="Submit">
                        <ExtraParams>
                            <ext:Parameter 
                                Name="data" 
                                Value="App.MultiSelect1.getStore().getRecordsValues()" 
                                Mode="Raw" 
                                Encode="true" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  5. #5
  6. #6
    Misunderstood the requirement. Here is a new example.

    Example
    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        public class Test
        {
            public string Value { get; set; }
            public string Text { get; set; }
        }
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.MultiSelect1.GetStore();
                store.DataSource = new object[] 
                { 
                    new Test()
                    {
                        Value = "1",
                        Text = "Item 1"   
                    },
                    new Test()
                    {
                        Value = "2",
                        Text = "Item 2"   
                    },
                    new Test()
                    {
                        Value = "3",
                        Text = "Item 3"   
                    }
                };
            }
        }
     
        protected void Submit(object sender, DirectEventArgs e)
        {
            Test selectedItem = JSON.Deserialize<Test>(e.ExtraParams["data"]);
    
            X.Msg.Alert("Submit", selectedItem.Text).Show();
        }
    </script>
     
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var getSelectedData = function () {
                var s = App.MultiSelect1.getSelected();
                
                if (s.length > 0) {
                    s = s[0].data;
                } 
    
                return Ext.encode(s);
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:MultiSelect
                ID="MultiSelect1"
                runat="server"
                ValueField="Value"
                DisplayField="Text"
                SingleSelect="true">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="Value" />
                                    <ext:ModelField Name="Text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
            </ext:MultiSelect>
     
            <ext:Button runat="server" Text="Submit">
                <DirectEvents>
                    <Click OnEvent="Submit" Before="return App.MultiSelect1.getSelected().length > 0;">
                        <ExtraParams>
                            <ext:Parameter
                                Name="data"
                                Value="getSelectedData()"
                                Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
    Quote Originally Posted by osef View Post
    I see the method "getRecordsValues()" is not in extjs 4.2.2 docs, Is this a new method?
    This method appeared in Ext.NET, not in ExtJS.
  7. #7
    Thank you Daniil, this is working, It only one thing, where is the docs of that method (getRecordsValues())?, because the server methods are here (http://docs.ext.net).
  8. #8
    Unfortunately, we have no docs for client side part of Ext.NET.
  9. #9
    Quote Originally Posted by Daniil View Post
    Unfortunately, we have no docs for client side part of Ext.NET.
    Thank you, you can to close this thread.

Similar Threads

  1. Replies: 17
    Last Post: Dec 17, 2012, 11:58 AM
  2. DrawText item with text from database/store?
    By KBorkiewicz in forum 2.x Help
    Replies: 0
    Last Post: Dec 05, 2012, 6:10 PM
  3. Replies: 0
    Last Post: Sep 22, 2010, 3:42 AM
  4. [CLOSED] Add or replace item in Store
    By macap in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 22, 2010, 3:17 PM
  5. [CLOSED] Store item id property
    By daneel in forum 1.x Help
    Replies: 4
    Last Post: Mar 15, 2010, 2:18 PM

Tags for this Thread

Posting Permissions