[CLOSED] Custom Search with X.GetCmp

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Custom Search with X.GetCmp

    Hi, I am trying to use below code to get Value of custom search combox in example:
    https://examples1.ext.net/#/Form/Com...Custom_Search/

    but it returns nothing. (*I gave ID to combox as cbxTest)
    The code works for regular combox. not sure what i am missing here
    [DirectMethod]
        public void Test()
        {
            string a = X.GetCmp<ComboBox>("cbxTest").Value.ToString();
        }
    Last edited by Daniil; Feb 18, 2011 at 9:38 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please use Page_Init instead Page_Load to create dynamic controls which will be used in other requests
  3. #3
    Thanks you, but the scenario is that custom search is dynamically generated in directevent . when a button is clicked on that form, i would like to get the value of the combobox. so the contorls won't be created in page_init.
  4. #4
    Hi,

    Please post test sample. Are you sure that combo is submitted own value (Request["cbxTest"])?
  5. #5
    All I did is to add the Test button on the custom search example to get value of NOT dynamically created search combobox and I gave id cbxTest to the combox since in the example there is no ID set for the control.
    Not getting anything back with code: X.getCmp<ComboBox>("cbxTest") syntax
  6. #6
    Hi,

    All I did is to add the Test button on the custom search example to get value of NOT dynamically created search combobox and I gave id cbxTest to the combox since in the example there is no ID set for the control.
    I cannot reproduce the issue (as I said you have to use Page_Init in that sample)

    Please post your sample which reproduces the problem
  7. #7
    Hi,

    I adding the code in according to the details you described and tested it, works fine.

    So, please provide us with a full sample to reproduce.

    Here is my test sample.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create Proxy
            HttpProxy proxy = new HttpProxy { 
                Method = HttpMethod.POST,
                Url = "Plants.ashx"
            };
            
            // Create Reader
            JsonReader reader = new JsonReader { 
                Root = "plants",
                TotalProperty = "total",
                Fields = {
                    new RecordField("Common"),
                    new RecordField("Botanical"),
                    new RecordField("Light"),
                    new RecordField("Price", RecordFieldType.Float),
                    new RecordField("Indoor", RecordFieldType.Boolean)
                }
            };
            
            // Add Proxy and Reader to Store
            Store store = new Store { 
                Proxy = { proxy },
                Reader = { reader },
                AutoLoad = false
            };
            
            // Create ComboBox
            ComboBox combobox = new ComboBox {
                DisplayField = "Common",
                ValueField = "Common",
                TypeAhead = false,
                LoadingText = "Searching...",
                Width = 570,
                PageSize = 10,
                HideTrigger = true,
                ItemSelector = "div.search-item",
                MinChars = 1,
                Store = { store }
            };
            
            combobox.Template.Html = @"
                   <tpl for=""."">
                      <div class=""search-item"">
                         <h3><span>${Price}</span>{Common}</h3>
                         {Botanical}
                      </div>
                   </tpl>";
    
            // Add ComboBox to Controls Collection
            this.Placeholder1.Controls.Add(combobox);
        }
    
        [DirectMethod]
        public void Test()
        {
            string a = X.GetCmp<ComboBox>("ComboBox1").Value.ToString();
            X.Msg.Alert("", a).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>ComboBox with Template - Ext.NET Examples</title>
        <style type="text/css">
            .search-item {
                font          : normal 11px tahoma, arial, helvetica, sans-serif;
                padding       : 3px 10px 3px 10px;
                border        : 1px solid #fff;
                border-bottom : 1px solid #eeeeee;
                white-space   : normal;
                color         : #555;
            }
            
            .search-item h3 {
                display     : block;
                font        : inherit;
                font-weight : bold;
                color       : #222;
            }
    
            .search-item h3 span {
                float       : right;
                font-weight : normal;
                margin      : 0 0 5px 5px;
                width       : 100px;
                display     : block;
                clear       : none;
            } 
            
            p { width: 650px; }
            
            .ext-ie .x-form-text { position : static !important; }
        </style>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <h1>Combo with Templates and Ajax</h1><br />
            <p>This is a more advanced example demonstrating how to combine Store Paging and a Template to create "live search" functionality.</p>
        
            <div style="width:600px;">
                <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
                <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
                    <h3 style="margin-bottom:5px;">Search the plants</h3>
                    
                <ext:ComboBox
                    ID="ComboBox1"
                    runat="server" 
                    DisplayField="Common" 
                    ValueField="Common"
                    TypeAhead="false"
                    LoadingText="Searching..." 
                    Width="570"
                    PageSize="10"
                    HideTrigger="true"
                    ItemSelector="div.search-item"        
                    MinChars="1">
                    <Store>
                        <ext:Store runat="server" AutoLoad="false">
                            <Proxy>
                                <ext:HttpProxy Method="POST" Url="Plants.ashx" />
                            </Proxy>
                            <Reader>
                                <ext:JsonReader Root="plants" TotalProperty="total">
                                    <Fields>
                                        <ext:RecordField Name="Common" />
                                        <ext:RecordField Name="Botanical" />
                                        <ext:RecordField Name="Light" />
                                        <ext:RecordField Name="Price" Type="Float" />
                                        <ext:RecordField Name="Indoor" Type="Boolean" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                    <Template runat="server">
                       <Html>
                           <tpl for=".">
                              <div class="search-item">
                                 <h3><span>${Price}</span>{Common}</h3>
                                 {Botanical}
                              </div>
                           </tpl>
                       </Html>
                    </Template>
                </ext:ComboBox>    
                
                <div style="padding-top:4px;">
                    Plants search (type '*' (asterisk) for showing all)
                </div>
                </div></div></div>
                <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
            </div>
                
            <br />
            <br />
            <br />
                
            <div style="width:600px;">
                <div class="x-box-tl">
                    <div class="x-box-tr">
                        <div class="x-box-tc"></div>
                    </div>
                </div>
                <div class="x-box-ml">
                    <div class="x-box-mr">
                        <div class="x-box-mc">
                            <h3 style="margin-bottom:5px;">Search the plants (controls dynamically created)</h3>
                            <asp:PlaceHolder ID="Placeholder1" runat="server" />
                            <div style="padding-top:4px;">
                                Plants search (type '*' (asterisk) for showing all)
                            </div>
                        </div>
                    </div>
                </div>
                <div class="x-box-bl">
                    <div class="x-box-br">
                        <div class="x-box-bc"></div>
                    </div>
                </div>
            </div>
            <ext:Button runat="server" Text="Click me">
                <Listeners>
                    <Click Handler="Ext.net.DirectMethods.Test();" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] [1.0] Custom search help
    By edigital in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Apr 10, 2015, 8:44 PM
  2. [CLOSED] [1.0] custom search
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 23, 2010, 4:48 PM
  3. [CLOSED] custom search v1.0 IE6
    By sharif in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 18, 2010, 8:05 PM
  4. [CLOSED] [1.0] ComboBox Custom Search
    By Ben in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 01, 2009, 8:00 PM
  5. Custom Search
    By sharif in forum 1.x Help
    Replies: 0
    Last Post: Jul 14, 2009, 5:04 PM

Posting Permissions