how to save comboboxvalue in grid

  1. #1

    how to save comboboxvalue in grid

    First, I have to tell you, I am a beginner with ext.net.


    I have some problem. My application has grid panel that has combobox inside. Users will select choice which they want.
    then they will click the button to save the data. the system will save row by row. So for get the static data I will get it from store.
    But for combobox, I don't know how to get. It has no data in the store.

    this is my screen. hope you can get a little bit more understand
    Click image for larger version. 

Name:	e.jpg 
Views:	105 
Size:	35.5 KB 
ID:	3794

    Please help me to solve the problem.

    If you not understand, please let me know. I'm not good in English.
  2. #2
    Hi,

    Welcome to Ext.NET!

    Could you provide a sample to reproduce the problem?
  3. #3
    Sorry, I'm late. Because of another project.

    This is code in my aspx file.

        <ext:Store ID="storeCboAppr" runat="server" OnRefreshData="storeCboAppr_RefreshData">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader IDProperty="VALUEFIELD">
                    <Fields>
                        <ext:RecordField Name="VALUEFIELD" />
                        <ext:RecordField Name="TEXTFIELD" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Store ID="Store1" runat="server" OnRefreshData="Store1_RefreshData">
            <Reader>
                <ext:JsonReader IDProperty="EMPLOYEE_EN">
                    <Fields>
                        <ext:RecordField Name="EMPLOYEE_EN" />
                        <ext:RecordField Name="EMPLOYEE_NAME" />
                        <ext:RecordField Name="SUPERVISOR_EN" />
                        <ext:RecordField Name="SUPERVISOR_NAME" />
                        <ext:RecordField Name="MANAGER_EN" />
                        <ext:RecordField Name="MANAGER_NAME" />
                        <ext:RecordField Name="APPROVAL" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" Cls="x-grid-custom" Header="true" Border="false"
            StripeRows="true" Title="Pending List" TrackMouseOver="true" StoreID="Store1"
            Height="300px">
            <ColumnModel ID="ColumnModel2" runat="server">
                <Columns>
                    <ext:Column ColumnID="EMPLOYEE_EN" Header="EMPLOYEE EN" DataIndex="EMPLOYEE_EN" />
                    <ext:Column Header="Employee NAME" DataIndex="EMPLOYEE_NAME" />
                    <ext:Column Header="SUPERVISOR EN" DataIndex="SUPERVISOR_EN" Hidden="True" />
                    <ext:Column Header="SUPERVISOR NAME" DataIndex="SUPERVISOR_NAME" />
                    <ext:Column Header="MANAGER EN" DataIndex="MANAGER_EN" Hidden="True" />
                    <ext:Column Header="MANAGER NAME" DataIndex="MANAGER_NAME" />
                    <ext:Column DataIndex="APPROVAL" Header="APPROVAL">
                        <Editor>
                            <ext:ComboBox ID="ComboBox1" runat="server" StoreID="storeCboAppr" ValueField="TEXTFIELD"
                                DisplayField="TEXTFIELD">
                                <CustomConfig>
                                    <ext:ConfigItem Name="initQuery" Value="Ext.emptyFn" Mode="Raw" />
                                </CustomConfig>
                            </ext:ComboBox>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <LoadMask ShowMask="true" />
            <Plugins>
                <ext:GridFilters runat="server" ID="GridFilters2" Local="true">
                    <Filters>
                        <ext:StringFilter DataIndex="EMPLOYEE_EN" />
                        <ext:StringFilter DataIndex="EMPLOYEE_NAME" />
                        <ext:StringFilter DataIndex="SUPERVISOR_EN" />
                        <ext:StringFilter DataIndex="SUPERVISOR_NAME" />
                        <ext:StringFilter DataIndex="MANAGER_EN" />
                        <ext:StringFilter DataIndex="MANAGER_NAME" />
                    </Filters>
                </ext:GridFilters>
            </Plugins>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar2" runat="server" PageSize="10" />
            </BottomBar>
            <View>
                <ext:GridView ID="GridView1" runat="server" ScrollOffset="2" />
            </View>
            <Buttons>
                <ext:Button ID="btnSubmit" runat="server" Text="Submit">
                    <DirectEvents>
                        <Click OnEvent="btnSubmit_Click">
                            <EventMask ShowMask="true" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
            <DirectEvents>
                <AfterEdit OnEvent="AfterEdit">
                    <EventMask ShowMask="true" Target="This" />
                    <ExtraParams>
                        <ext:Parameter Name="field" Value="e.field" Mode="Raw" />
                        <ext:Parameter Name="id" Value="e.record.id" Mode="Raw" />
                        <ext:Parameter Name="record" Value="e.record.data" Mode="Raw" Encode="true" />
                    </ExtraParams>
                </AfterEdit>
            </DirectEvents>
        </ext:GridPanel>
    And form the example in this
    I think I should to use AfterEdit event. Below is my AfterEdit.
            protected void AfterEdit(object sender, DirectEventArgs e)
            {
                List<string> fields = new List<string> { "EMPLOYEE_EN", "EMPLOYEE_NAME", "SUPERVISOR_EN", "SUPERVISOR_NAME", "MANAGER_EN", "MANAGER_NAME", "APPROVAL"};
                int startIndex = fields.IndexOf(e.ExtraParams["field"]);
                JsonObject data = JSON.Deserialize<JsonObject>(e.ExtraParams["record"]);
                string approvalStatus = data["APPROVAL"].ToString();
                this.Store1.UpdateRecordField(e.ExtraParams["id"], fields[startIndex], data["APPROVAL"]);
                DataTable dt = (DataTable)(this.Store1.DataSource);
            }
    But I cannot retrieve anything from store1.datasource.



    remark
    Actually, I think this way(AfterEdit) is not the best way to save data to table. My opinion is save it row by row after click submit button and AfterEdit will not use in my application same as web form gridview rows looping is so easy and better. But I do not know how to do that.
    Last edited by innerstream; Feb 08, 2012 at 7:56 AM.
  4. #4
    From this, I found a solution already.

    In button code, I have changed to be below

    <Buttons>
        <ext:Button ID="btnSubmit" runat="server" Text="Submit">
            <DirectEvents>
                <Click OnEvent="btnSubmit_Click">
                    <ExtraParams>
                        <ext:Parameter Name="rowsValues" Value="#{GridPanel1}.getRowsValues(false)" Mode="Raw"
                            Encode="true" />
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
    </Buttons>
    Thank you for your support.
    Last edited by innerstream; Feb 08, 2012 at 8:27 AM. Reason: Solved
  5. #5
    Ok, thanks for the update.

Similar Threads

  1. Replies: 1
    Last Post: Jul 27, 2011, 10:19 AM
  2. [CLOSED] Save Grid settings
    By Raynald_Fontaine in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 19, 2010, 5:44 PM
  3. Help! Grid deleteing rows on save!!!!
    By Tbaseflug in forum 1.x Help
    Replies: 6
    Last Post: Jan 18, 2010, 8:36 PM
  4. grid save and reload
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Aug 10, 2009, 4:18 AM
  5. How to Save Grid Content
    By nanosassa in forum 1.x Help
    Replies: 1
    Last Post: May 09, 2009, 12:29 PM

Tags for this Thread

Posting Permissions