Restful Store and SubmitEmptyValue

  1. #1

    Restful Store and SubmitEmptyValue

    Hello,

    The following code is based on your MVC RESTful example. In the webpage I have:

    1) Simple Store:
         <ext:Store ID="Store1" runat="server" AutoSave="true" Restful="true">
                <Proxy>
                    <ext:HttpProxy>                        
                        <RestAPI   CreateUrl="/Customer/Create" ...   />             
                     </ext:HttpProxy>
                </Proxy>
                    
                <Reader>
                    <ext:JsonReader
                        IDProperty="id" 
                        Root="data" 
                        MessageProperty="message">
                        <Fields>
                            <ext:RecordField Name="id" />
                            <ext:RecordField Name="email" type="String" SubmitEmptyValue="Null" />
                            <ext:RecordField Name="lastname" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
    2) Simple FormPanel:
    <ext:FormPanel ID="FormPanel1" runat="server">
        <Items>           
           <ext:TextField ID="EmailField" DataIndex="email" runat="server" FieldLabel="Email"  Vtype="email" AllowBlank="true" />
           <ext:TextField ID="LastField" DataIndex="lastname" runat="server" FieldLabel="Last" />
        </Items>
        <Buttons>
             <ext:Button ID="Button5" runat="server" Text="Προσθήκη" Icon="Add">
                 <Listeners>
                     <Click Handler="if (#{FormPanel1}.getForm().isValid()) #{Store1}.addRecord(#{FormPanel1}.getForm().getFieldValues(false, 'dataIndex'),false, true);" />
                 </Listeners>
              </ext:Button>
        </Buttons>
    The controller's Create action is the following:
    [AcceptVerbs(HttpVerbs.Post)]
    public RestResult Create(string data)
    {
        try
        {
             Customer c = JSON.Deserialize<Customer>(data);
             DataContext context = this.DBContext;
             context.Owners.InsertOnSubmit(c);
             context.SubmitChanges();
             return new RestResult
             {
                 Success = true,
                 Message = "Inserted",
                 Data =  c
             };        
        }
        catch (...) { ... }
    }
    Insertion works fine except empty strings ("") are inserted instead of Null when the form fields are not filled. This happens whether SubmitEmptyValue is set to "Null" (e.g. email field) or not (e.g. Lastname field).

    Why? How can this be fixed?

    Thank you very much in advance.
  2. #2
    I did some digging and the situation is irrelevant to REST (I've tried with a LinqDataSource in a classic asp.net website). Furthermore, I found that changing the dirtyOnly parameter of the getFieldValues function to true won't make any difference.

    So, the question still applies: Can the form be configured to submit only dirty fields and let everything else to NULL instead of empty string?

    PS: I would really appreciate it if you could answer my question. Since I've paid for my license key I've never received an answer in the forum, which is frustrating, really.

Similar Threads

  1. Replies: 3
    Last Post: Jan 19, 2012, 9:56 AM
  2. RESTful MVC bind Model to Store
    By Dominik in forum 1.x Help
    Replies: 6
    Last Post: Nov 10, 2011, 2:34 PM
  3. [CLOSED] [1.0] Restful Store API
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Oct 22, 2010, 7:13 AM
  4. [CLOSED] [1.0] Store Restful
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 04, 2010, 4:50 PM
  5. [CLOSED] Restful Store Question
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 20, 2010, 2:23 PM

Tags for this Thread

Posting Permissions