[CLOSED] [1.0] Store Submit Question

  1. #1

    [CLOSED] [1.0] Store Submit Question

    I'm working with the newest SVN release and it appears there was change somewhere so if you submit the values from a Gridpanel (Store Submit). The xml will omit records that have null values. Has this changed? My code requires that I have the xml element even if the value is null.

    Is this a bug or has it been changed, just need to know so I can adjust my code.

    <ext:Parameter Name="Values" Value="Ext.encode(#{gEmployeeswip}.getRowsValues())" Mode="Raw" />
    I believe this is what isn't giving me all the data I need.
    Last edited by geoffrey.mcgill; Aug 20, 2010 at 2:29 PM. Reason: [CLOSED]
  2. #2
    I believe this function

    getRowsValues: function (config) {
        config = config || {};
        this.stopEditing(false);
        var records = (config.selectedOnly ? this.selModel.getSelections() : config.currentPageOnly ? this.store.getRange() : this.store.getAllRange()) || [], values = [], record, i; if (this.selectionMemory && config.selectedOnly && !config.currentPageOnly && this.store.isPagingStore()) { records = []; for (var id in this.selectedIds) { record = this.store.getById(this.selectedIds[id].id); if (!Ext.isEmpty(record)) { records.push(record); } } }
        for (i = 0; i < records.length; i++) {
            var obj = {}, dataR; if (this.store.metaId()) { obj[this.store.metaId()] = records[i].id; }
            dataR = Ext.apply(obj, records[i].data);
            config.grid = this;
            dataR = this.store.prepareRecord(dataR, records[i], config);
            if (!Ext.isEmptyObj(dataR)) { values.push(dataR); }
    Was changed to not push the value if it's Empty, if that's the case can we add a check if we pass in a parameter it will pass these null values, default to false?
  3. #3
    Hello!

    Please clarify what exactly empty values do you mean? I tried null and "" values and it seems it works fine.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.Store.Primary;
                store.DataSource = new object[] { 
                                             new object[] {"3m Co", null, ""},
                                             new object[] {"Alcoa Inc", null, ""},
                                             new object[] {"Altria Group Inc", null, ""}
                                    };
                store.DataBind();
            }
        }
        protected void Button_Click(object sender, DirectEventArgs e)
        {
            String values = e.ExtraParams["Values"];
            X.Msg.Alert("Values", values).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                    <ext:Column Header="Test2" DataIndex="test2" />
                    <ext:Column Header="Test3" DataIndex="test3" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        <ext:Button runat="server" Text="Submit">
            <DirectEvents>
                <Click OnEvent="Button_Click">
                    <ExtraParams>
                        <ext:Parameter Name="Values" Value="#{GridPanel1}.getRowsValues()"
                            Mode="Raw" Encode="true"/>
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
  4. #4
    Yeah I just looked that works, I'm thinking it wasn't getRowsValues but the StoreSubmitEventArgs

    where I'm trying to output the submitted data as an xmlnodelist

    example
    Dim xml As XmlNode = e.Xml
    For now I guess I'll just check if the xml element is null I'll just have to update my code.
  5. #5
    Ok I found the problem, uses your code you supplied below but change the last record type in the store to a "Date"

    you will see it will NOT append that value to your output

    example

    <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" type="Date" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
  6. #6
    Quote Originally Posted by ljankowski View Post
    Ok I found the problem, uses your code you supplied below but change the last record type in the store to a "Date"

    you will see it will NOT append that value to your output

    example

    <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" type="Date" SubmitEmptyValue="EmptyString">
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
    Found the problem SubmitEmptyValue fixes my problem, thanks

    It appears if you add a type value, and it's null it doesn't pass the value on a submit anymore, you have to allow it by SubmitEmptyValue

    [{"id":-1,"test":"3m Co","test2":null},{"id":-2,"test":"Alcoa Inc","test2":null},{"id":-3,"test":"Altria Group Inc","test2":null}]
    Last edited by geoffrey.mcgill; Aug 20, 2010 at 5:57 PM.

Similar Threads

  1. Replies: 1
    Last Post: Jul 25, 2012, 9:52 AM
  2. Replies: 4
    Last Post: Jul 08, 2011, 4:23 PM
  3. about store RecordField submit emptystring issue
    By new163_2 in forum 1.x Help
    Replies: 1
    Last Post: Jun 14, 2011, 1:53 PM
  4. [CLOSED] Store Question
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Feb 25, 2011, 12:02 AM
  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