Apr 19, 2012, 1:54 PM
[CLOSED] Editor field mapping: Missing combobox display text on gridpanel load
Hi,
We have a gridpanel with 2 textfields and 1 combobox columns.
The binding works well but when the gridpanel is loaded all data is dispalyed correctly except for the combobox column which is blank.
The hic is that when I click manually on the "refresh" button of the grid, combobox column content is shown with correct value.
Below a sample in order to reproduce the issue:
ASPX view code :
We have a gridpanel with 2 textfields and 1 combobox columns.
The binding works well but when the gridpanel is loaded all data is dispalyed correctly except for the combobox column which is blank.
The hic is that when I click manually on the "refresh" button of the grid, combobox column content is shown with correct value.
Below a sample in order to reproduce the issue:
ASPX view code :
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<head runat="server">
<script type="text/javascript">
var groupRenderer = function (value) {
var r = _comboGroupStore.getById(value);
if (Ext.isEmpty(r)) {
return "";
}
return r.data.GoupName;
};
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanelUsrGroup" runat="server" Header="false" Border="false"
AutoWidth="true" AutoHeight="true" StripeRows="true" IDMode="Static">
<View>
<ext:GridView ID="GridViewUserGroup" runat="server" ForceFit="true" AutoFill="true" />
</View>
<Store>
<ext:Store ID="dsUsrGroup" runat="server" SkipIdForNewRecords="false">
<Proxy>
<ext:HttpProxy Url="/Research/GetUsersList" />
</Proxy>
<Reader>
<ext:JsonReader Root="data" TotalProperty="total">
<Fields>
<ext:RecordField Name="GroupId">
</ext:RecordField>
<ext:RecordField Name="UserId">
</ext:RecordField>
<ext:RecordField Name="UserName">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModelUsrGroup" runat="server">
<Columns>
<ext:Column ColumnID="_groupShortname" DataIndex="GroupId" Header="Group shortname">
<Renderer Fn="groupRenderer" />
<Editor>
<ext:ComboBox ID="_comboGroupShortname" runat="server" AnchorHorizontal="25%" DisplayField="GoupName"
ValueField="GroupId" ForceSelection="true" >
<Store>
<ext:Store ID="_comboGroupStore" runat="server" AutoLoad="true">
<Proxy>
<ext:HttpProxy Url="/Research/GetGroupsList">
</ext:HttpProxy>
</Proxy>
<Reader>
<ext:JsonReader IDProperty="GroupId" Root="data" TotalProperty="total">
<Fields>
<ext:RecordField Name="GroupId" ServerMapping="GroupId.Value">
</ext:RecordField>
<ext:RecordField Name="GoupName" ServerMapping="GoupName.Value">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
</ext:ComboBox>
</Editor>
</ext:Column>
<ext:Column DataIndex="UserId" Header="Id">
</ext:Column>
<ext:Column DataIndex="UserName" Header="UserName">
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModelUserGrp" runat="server" />
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbarUserGrp" runat="server" PageSize="5" />
</BottomBar>
<LoadMask ShowMask="true" />
</ext:GridPanel>
</body>
</html>
Controller code : public class User
{
int userId;
public int UserId
{
get { return userId; }
set { userId = value; }
}
String userName;
public String UserName
{
get { return userName; }
set { userName = value; }
}
int groupId;
public int GroupId
{
get { return groupId; }
set { groupId = value; }
}
}
public class Group
{
int groupId;
public int GroupId
{
get { return groupId; }
set { groupId = value; }
}
String goupName;
public String GoupName
{
get { return goupName; }
set { goupName = value; }
}
}
public class ResearchController : Controller
{
public ActionResult UserGroupGrid()
{
return View();
}
public AjaxStoreResult GetUsersList()
{
List<User> users = new List<User>();
User user = new User();
user.UserId = 1;
user.UserName = "User";
user.GroupId = 1;
users.Add(user);
AjaxStoreResult result = new AjaxStoreResult();
result.Data = users;
result.Total = 1;
return result;
}
public AjaxStoreResult GetGroupsList()
{
List<Group> groups = new List<Group>();
Group group = new Group();
group.GroupId = 1;
group.GoupName = "Group";
groups.Add(group);
AjaxStoreResult result = new AjaxStoreResult();
result.Data = groups;
return result;
}
}
Thank you in advance.
Last edited by Daniil; Apr 19, 2012 at 7:09 PM.
Reason: [CLOSED]