[CLOSED] Custom Search Combobox setValue not Working in Ext 2.2

  1. #1

    [CLOSED] Custom Search Combobox setValue not Working in Ext 2.2

    i have created custom search combobox

    in combobox's render listener i am setting the combobx value by
    setValue and setRawValue

    it is working but when i press down arrow key the value which i have set
    is not selected (it is working properly in version 1.1)

    as per documented for combobox

    setvalue method fires events -
    change
    dirtychange
    validitychange

    how to prevent for firing the change event?

    it is not working by using suspendEvents() and resumeEvents() in ie

    how to achieve it?

    In Ext.net 1.1



    <ext:ComboBox 
                    runat="server" 
                    DisplayField="Name" 
                    ValueField="ID"
                    
                    TypeAhead="false"
                    LoadingText="Searching..." 
                    Width="400"
                    PageSize="10"
                    HideTrigger="true"
                    ItemSelector="div.search-item"        
                    MinChars="1">
                    <Store>
                        <ext:Store runat="server" AutoLoad="false">
                            <Proxy>
                                <ext:HttpProxy Method="POST" Url="Filter.ashx" />
                            </Proxy>
                            <Reader>
                                <ext:JsonReader Root="values" TotalProperty="total">
                                    <Fields>
                                        <ext:RecordField Name="ID" />
                                        <ext:RecordField Name="Name" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                    <Template runat="server">
                       <Html>
                           <tpl for=".">
                              <div class="search-item">
                                 <h3>{Name}</h3>
                              </div>
                           </tpl>
                       </Html>
                    </Template>
                </ext:ComboBox>
    In Ext.net 2.2Click image for larger version. 

Name:	1.JPG 
Views:	41 
Size:	9.3 KB 
ID:	6744Click image for larger version. 

Name:	2.JPG 
Views:	30 
Size:	16.0 KB 
ID:	6745

    <ext:ComboBox 
                    runat="server" 
                    DisplayField="Name" 
                    ValueField="ID"
                    TypeAhead="false"
                    Width="400"
                    PageSize="10"
                    HideBaseTrigger="true"
                    MinChars="0"
                    TriggerAction="Query">
                    <ListConfig  LoadingText="Searching...">
                        <ItemTpl runat="server">
                            <Html>
                                <div class="search-item">
                                    <h3>{Name}</h3>
                                </div>
                            </Html>
                        </ItemTpl>
                    </ListConfig>
                    <Store>
                        <ext:Store runat="server" AutoLoad="false">
                            <Proxy>
                                <ext:AjaxProxy Url="Filter.ashx">
                                    <ActionMethods Read="POST" />
                                    <Reader>
                                        <ext:JsonReader Root="values" TotalProperty="total" />
                                    </Reader>
                                </ext:AjaxProxy>
                            </Proxy>
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="ID" />
                                        <ext:ModelField Name="Name" />
                                    </Fields>
                                </ext:Model>                            
                            </Model>
                        </ext:Store>
                    </Store>
                </ext:ComboBox>

    Protected void setCmbValue()
    {
    ddlStore.DataSource = lstVal;
    ddl.Listeners.Render.Handler = "this.setValue('" + lstVal[0].ID + "');this.setRawValue('" + lstVal[0].Name + "');";
    ddl.Listeners.Render.Delay = 1;
    ddlStore.DataBind();
    }
    Filter.ashx

    public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/json";
    
                var x = new StoreRequestParameters(context);
    
                var start = 0;
                var limit = 2;
                var sort = string.Empty;
                var dir = string.Empty;
                var filter = string.Empty;
    
                IList<object> data = new List<object>();
    
                if (!string.IsNullOrEmpty(context.Request["start"]))
                {
                    start = int.Parse(context.Request["start"]);
                }
    
                if (!string.IsNullOrEmpty(context.Request["limit"]))
                {
                    limit = int.Parse(context.Request["limit"]);
                }
    
                if (!string.IsNullOrEmpty(context.Request["sort"]))
                {
                    sort = context.Request["sort"];
                }
    
                if (!string.IsNullOrEmpty(context.Request["dir"]))
                {
                    dir = context.Request["dir"];
                }
    
                if (!string.IsNullOrEmpty(context.Request["query"]))
                {
                    filter = context.Request["query"];
                }
    
                Paging<tblUser> objUser = null;
    
                objUser = FilterUser(start, limit, sort, dir, filter);
                
                context.Response.Write(string.Format("{{total:{1},'values':{0}}}", JSON.Serialize(objUser.Data), objUser.TotalRecords));
            }
    
    public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
    
    public static Paging<tblUser> FilterUser(int start, int limit, string sort, string dir, string filter)
            {
                List<tblUser> lstUser = null;
                tblUser objUser = new tblUser();
                List<tblUser> rangeValues = null;
    
                lstUser = objUser.FetchUser(filter, start, limit).ToList<tblUser>();
    
                CommonProperty c = new CommonProperty();
                c.TotalRecords = objUser.TotalRecords;
    
                if ((start + limit) > c.TotalRecords)
                {
                    limit = lstUser.Count - start;
                }
                
    
                if (limit == 0)
                    rangeValues = (start < 0 || limit < 0) ? lstUser : lstUser.GetRange(0, limit);
                else
                    rangeValues = (start < 0 || limit < 0) ? lstUser : lstUser.GetRange(0, limit);
    
                
                if (lstUser != null)
                    return new Paging<tblUser>(rangeValues, c.TotalRecords);
                else
                    return new Paging<tblUser>(new List<tblUser>(), 0);
            }
    Last edited by Daniil; Aug 20, 2013 at 9:09 AM. Reason: [CLOSED]
  2. #2
    Hi @legaldiscovery,

    So, the task is to set up an initial value for a ComboBox. This problem was discussed here:
    http://forums.ext.net/showthread.php?22653

    I can confirm that some tricky solutions for this task in v1 no longer work in v2.

Similar Threads

  1. Custom Search with ComboBox
    By Vinci in forum 2.x Help
    Replies: 1
    Last Post: May 23, 2013, 8:01 AM
  2. Replies: 12
    Last Post: Dec 11, 2012, 3:38 AM
  3. [CLOSED] SetValue with custom search (combobox)
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Jul 06, 2012, 12:36 PM
  4. [CLOSED] combobox setvalue if smart search not found
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 18, 2012, 7:18 AM
  5. custom search in combobox
    By aditya.murthy88@gmail.com in forum 1.x Help
    Replies: 0
    Last Post: Feb 05, 2011, 8:57 AM

Posting Permissions