[CLOSED] Editor field mapping: Missing combobox display text on gridpanel load

  1. #1

    [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 :
    <%@ 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]
  2. #2
    Hi,

    I think it means that the ComboBox Store is not loaded when grid rows rendering happens.

    You should be able to fix the problem refreshing the grid after loading a data into the ComboBox Store.

    Please set up
    <Load Handler="#{GridPanelUsrGroup}.getView().refresh();" />
    listener for the ComboBox Store.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    I think it means that the ComboBox Store is not loaded when grid rows rendering happens.

    You should be able to fix the problem refreshing the grid after loading a data into the ComboBox Store.

    Please set up
    <Load Handler="#{GridPanelUsrGroup}.getView().refresh();" />
    listener for the ComboBox Store.
    Thanks it works
  4. #4

    how to Attach Javascript functions to gridpanel combobox column selection change event..?

    Hi,

    i m new to Ext.net gridpanel. what i m trying to do is, populate gridpanel from code behind. i've populated three column 2 text column and 1 combobox column. i want to add fallowing functionality to the combobox column. i m using asp.net with VB.

    When user selects any item out of combobox, it should trigger some clientside/javascript function which will receive valuemember of current selected item in the combobox, as parameter. and on the basis of that i will do some calculations and put some value another column of same row of the gird.

    For Ex. I'll select TAX percentage from dropdown, and there will be two columns in the grid (first will display the Tax percentage and another will display a calculated amount of tax on the basis of selected tax percentage.

    any help will be appreciated.
  5. #5
    Hi @hemantpatil,

    Welcome to Ext.NET forums!

    Your question appears to be not related to the topic of the current thread. Please start a new forum thread.

Similar Threads

  1. Replies: 1
    Last Post: Apr 09, 2012, 5:03 PM
  2. [CLOSED] GridPanel Editor field mapping problem
    By kenanhancer in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 01, 2011, 7:42 AM
  3. Editor Field Mapping not working in MVC2?
    By paxos in forum 1.x Help
    Replies: 4
    Last Post: Apr 27, 2010, 11:03 AM
  4. Replies: 6
    Last Post: Feb 22, 2010, 1:18 AM
  5. ComboBox in GP Editor - Display Text Vs Value
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Apr 15, 2009, 4:47 PM

Posting Permissions