[CLOSED] Submit combobox value within an editable gridview

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Submit combobox value within an editable gridview

    Hi,
    How to submit combobox value within an editable gridview ?

    This is the gridview 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">
        <meta name="viewport" content="width=device-width" />
    </head>
    <body>
        <ext:ResourceManager runat="server">
        </ext:ResourceManager>
        <ext:GridPanel ID="GridPanelUsrGroup" runat="server" Header="false" Border="false"
            TrackMouseOver="true" AutoWidth="true" AutoHeight="true">
            <View>
                <ext:GridView ID="GridView1" runat="server" ForceFit="true" />
            </View>
            <Store>
                <ext:Store ID="dsUsrGroup" runat="server" RemoteSort="true">
                    <UpdateProxy>
                        <ext:HttpWriteProxy Url="/Research/AssignUserGroup">
                        </ext:HttpWriteProxy>
                    </UpdateProxy>
                    <Reader>
                        <ext:JsonReader IDProperty="group_id" Root="data" TotalProperty="total">
                            <Fields>
                                <ext:RecordField Name="group_id">
                                </ext:RecordField>
                                <ext:RecordField Name="Supervisor">
                                    <Convert Handler="return value === 'Y' ? true : false;" />
                                </ext:RecordField>
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                    <WriteBaseParams>
                        <ext:Parameter Name="userId" Value="190" Mode="Value" AutoDataBind="true">
                        </ext:Parameter>
                    </WriteBaseParams>
                    <Listeners>
                        <Save Handler="Ext.net.Notification.show({iconCls: 'icon-information', html : arg.message, title : 'Success', hideDelay : 5000});" />
                        <Exception Handler="Ext.net.Notification.show({iconCls: 'icon-exclamation', html : e && e.message ? e.message : response.message || response.statusText, title : 'EXCEPTION', hideDelay : 5000});" />
                    </Listeners>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModelUsrGroup" runat="server">
                <Columns>
                    <ext:CheckColumn ColumnID="_groupSupervisor" DataIndex="Supervisor" Header="Supervisor"
                        Editable="true">
                    </ext:CheckColumn>
                    <ext:Column ColumnID="_groupShortname" DataIndex="group_id" Header="Group shortname"
                        Editable="true">
                        <Editor>
                            <ext:ComboBox ID="_comboGroupShortname" runat="server" AutoDataBind="true" AnchorHorizontal="25%"
                                SubmitValue="true">
                                <Items>
                                    <ext:ListItem Value="1" Text="X" />
                                    <ext:ListItem Value="2" Text="Y" />
                                </Items>
                            </ext:ComboBox>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button ID="Button1" runat="server" Text="Save" Icon="Disk">
                            <Listeners>
                                <Click Handler="#{dsUsrGroup}.save();" />
                            </Listeners>
                        </ext:Button>
                        <ext:Button ID="Button3" runat="server" Text="Add" Icon="Add">
                            <Listeners>
                                <Click Handler="#{GridPanelUsrGroup}.insertRecord(0, {});#{GridPanelUsrGroup}.getView().focusRow(0);#{GridPanelUsrGroup}.startEditing(0, 0);" />
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarSeparator ID="ToolbarSeparator1" runat="server" />
                        <ext:Label ID="Label1" runat="server" Text="(Double-Click Row to Edit)" />
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModelUserGrp" runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbarUserGrp" runat="server" PageSize="5" />
            </BottomBar>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
        </ext:GridPanel>
    </body>
    </html>
    This is the action that submit values :
      
    public AjaxStoreResult AssignUserGroup(int userId)
            {
                AjaxStoreResult ajaxStoreResult = new AjaxStoreResult(StoreResponseFormat.Save);
                try
                {
                    StoreDataHandler dataHandler = new StoreDataHandler(HttpContext.Request["data"]);
                    ChangeRecords<user_group> data = dataHandler.ObjectData<user_group>();
                    foreach (user_group usrGroup in data.Created)
                    {
                        if (usrGroup.Supervisor.Equals("True"))
                        {
                            usrGroup.Supervisor = "Y";
                        }
                         usrGroup.user_id = userId;
                        //_userGroupRepository.Add(usrGroup);
                    }
                    ajaxStoreResult.SaveResponse.Success = true;
                    ajaxStoreResult.SaveResponse.Message = "Success";
                }
                catch (Exception e)
                {
                    ajaxStoreResult.SaveResponse.Success = false;
                    ajaxStoreResult.SaveResponse.Message = e.Message;
                }
                return ajaxStoreResult;
            }
    This is the class user group :
     public class user_group
        {
            public int user_id
            {
                get;
                set;
            }
        
            public int group_id
            {
                get;
                set;
            }
            private int _group_id;
        
            public string Supervisor
            {
                get;
                set;
            }
    When I debug AssignUserGroup action I found group_id = 0.

    PS: I populate combobox with a datatable result to simplify issue I implemented a listItem.
    Last edited by Daniil; Apr 18, 2012 at 9:10 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please open the Ext.Net.MVC.Demo project (it's available in SVN).

    There is the SaveCustomersWithoutConfirmation controller action within the DataController which demonstrates how to get a saved data.

    StoreDataHandler dataHandler = new StoreDataHandler(HttpContext.Request["data"]);
    ChangeRecords<Customer> data = dataHandler.ObjectData<Customer>();
    You should use your class instead of Customer.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please open the Ext.Net.MVC.Demo project (it's available in SVN).

    There is the SaveCustomersWithoutConfirmation controller action within the DataController which demonstrates how to get a saved data.

    StoreDataHandler dataHandler = new StoreDataHandler(HttpContext.Request["data"]);
    ChangeRecords<Customer> data = dataHandler.ObjectData<Customer>();
    You should use your class instead of Customer.
    Yes I used it, just I don't found the attribute value group_id coming from the combobox
  4. #4
    Oh, I see.

    Please set up
     SkipIdForNewRecords="false"
    for the Store.
  5. #5
    Quote Originally Posted by Daniil View Post
    Oh, I see.

    Please set up
     SkipIdForNewRecords="false"
    for the Store.
    When I use
     SkipIdForNewRecords="false"
    I obtain a negative value which does not correspond to the combobox key value
  6. #6
    Please try to remove:
    IDProperty="group_id"
    of the JsonReader.
  7. #7
    Quote Originally Posted by Daniil View Post
    Please try to remove:
    IDProperty="group_id"
    of the JsonReader.
    Thanks it works but it display the key value of combobox after after submiting values
  8. #8
    I think you should set up a respective Renderer for the Column.

    Something like the Renderer of the Department Column in this example.
    https://examples2.ext.net/#/GridPane...Field_Mapping/
  9. #9
    Quote Originally Posted by Daniil View Post
    I think you should set up a respective Renderer for the Column.

    Something like the Renderer of the Department Column in this example.
    https://examples2.ext.net/#/GridPane...Field_Mapping/
    Daniil I use ext.net 1.3, the link redirect me to the ext.net 2.0 examples
  10. #10
    My fault, here is the link for v1.
    https://examples1.ext.net/#/GridPane...Field_Mapping/
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jul 25, 2012, 9:52 AM
  2. [CLOSED] V2.0 ComboBox Editable
    By Aurelio in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 23, 2012, 10:37 AM
  3. [CLOSED] ComboBox in Editable GridPanel
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 29, 2011, 3:00 PM
  4. [CLOSED] Editable Combobox
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 13, 2010, 2:28 PM
  5. [CLOSED] Submit gridpanel data in form submit
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 14, 2010, 7:25 PM

Posting Permissions