Aug 06, 2013, 10:29 AM
[FIXED] [#318] [2.2.0] Facing Problem of custom search combobox in 2.2
-> as per my requirement for custom search combobox
i have the id as integer value in valuefield and name as string in displayfield
my combobox is enabled for paging from handler
here my problem is that
in version 1.1 - when i do paging after selecting value from combobox the selected value and text is displayed properly (in image 1.1)
in version 2.2 - when i do paging after selecting value from combobox the selected value is displayed as text (in image 2.2)
-> how to resolve this ? is combobx is refreshing while doing paging in 2.2?
here is code
Code in Version 1.1
Page -> Filter.ashx
i have the id as integer value in valuefield and name as string in displayfield
my combobox is enabled for paging from handler
here my problem is that
in version 1.1 - when i do paging after selecting value from combobox the selected value and text is displayed properly (in image 1.1)
in version 2.2 - when i do paging after selecting value from combobox the selected value is displayed as text (in image 2.2)
-> how to resolve this ? is combobx is refreshing while doing paging in 2.2?
here is code
Code in Version 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>
Code in Version 2.2<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>
Page -> 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 fabricio.murta; Apr 27, 2016 at 1:19 AM.