Store AutoSave

  1. #1

    Store AutoSave

    Is there a known issue with the following setup (psuedoCode):

    Grid (w/ AutoSave="true") referencing a Store which references an ObjectDataSource, but when a delete occurs the ObjectDataSource is not notified until an Insert or Update occur on the store.

      <asp:ObjectDataSource ID="Ods1" runat="server ...>
       ....
       </asp:ObjectDataSource>
      <ext:Store ID="Store1" DataSourceID="Ods1" AutoSave="true" runat="server" >
      ...
      </ext:Store>
      ....
      <ext:GridPanel ID="GridPanel1" StoreID="Store1" runat="server" ...>
    I was trying the AutoSave="true" just to get things started. I plan to move to a commit button (I think). The issue that I am having right know is when I remove an item from the grid panel it is not triggering a call to the ObjectDataSource. When I update a row a call is made to the ObjectDataSource for the update and then the delete. So the store new that it deleted row was dirty, but for some reason during the grid.deleteSelected() the ObjectDataSource DeleteMethod didn't get called.

    The form is integrated with a lot of other stuff so I do not have a simple example. But the Insert and Update are working just fine.
  2. #2
  3. #3
    Thanks. So many things to learn and remember. I didn't read the Sencha 3.4 documenation on Store::autoSave which does say:

    Defaults to true causing the store to automatically save records to the server when a record is modified (ie: becomes 'dirty'). Specify false to manually call save to send all modifiedRecords to the server.

    Note: each CRUD action will be sent as a separate request.

    Defaults to: true
    I was actually looking at the extjs/src/Store.js code to learn about the configuration option. The code actually says:

    autoSave: false // <-- false to delay executing create, update, destroy requests until specifically told to do so.
    First the 3.4 documentation says that it defaults to true, but the code actually shows it defaulting to false (I think) and when I saw it say create/update/destroy I thought it meant insert/update/delete. So in general I was confussed.

    Thanks for the response.
  4. #4
    Apologize, I mislead you.

    1. There is the correct info in the ExtJS sources. I'm about this:
    autoSave: false    // <-- false to delay executing create, update, destroy requests until specifically told to do so.
    2. ExtJS should correct the autoSave docs article, since it works not for modified records only, it works for deleted and created ones as well. It really confuses.

    3. We overrode the default autoSave value to false, because, we think, it uses much more often.

    4. To get a save request for a deleted record, that record must not be a phantom.
    http://docs.sencha.com/ext-js/3-4/#!...operty-phantom

    I.e. a record should get its id from its data, not be auto-generated. In other words, a Store's Reader should have a RecordField with "id" Name or an IDProperty to be set up.

    Please look at the example.

    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.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" },
                    new object[] { "test3" }
                };
                store.DataBind();
            }
        }
    </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" AutoSave="true" RefreshAfterSaving="None">
                        <Reader>
                            <ext:ArrayReader IDProperty="test">
                                <Fields>
                                    <ext:RecordField Name="test" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                        <Listeners>
                            <BeforeSave Handler="alert('Save');" />
                        </Listeners>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test" DataIndex="test">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server">
                        <SelectedRows>
                            <ext:SelectedRow RowIndex="1" />
                        </SelectedRows>
                    </ext:RowSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
            <ext:Button runat="server" Text="Delete a selected">
                <Listeners>
                    <Click Handler="GridPanel1.deleteSelected();" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  5. #5
    Thanks. I have begun to review the source code more than reading the Sencha documents and the non-existant Ext.NET on-line documents because of some inconsistancys. I agree they should update there 3.4 docs for Store:autoSave. Store:autoSave is no longer defined in ExtJS 4.0 so not an issue.

    I will try everything tomorrow at work and reply back on the thread as to the success or additional problems.
  6. #6
    We have online server side API docs.
    http://docs.ext.net/

    Though, unfortunately, they are not fully filled.

    Also, Intellisense might be really useful:
    Click image for larger version. 

Name:	Intellisense.png 
Views:	146 
Size:	26.5 KB 
ID:	3677

    Though, we should also correct autoSave docs article.

Similar Threads

  1. [1.2] Postback on null values with autosave
    By hc.dev in forum 1.x Help
    Replies: 4
    Last Post: Jan 04, 2012, 4:52 PM
  2. Grid with AutoSave sample
    By PetrSnobelt in forum 1.x Help
    Replies: 3
    Last Post: Apr 27, 2011, 11:33 AM
  3. [CLOSED] Gridpanel - RowEditor - Autosave
    By jthompson in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 05, 2011, 8:39 AM
  4. [CLOSED] autosave on gridpanel
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 08, 2011, 2:42 PM
  5. [1.0] Examples Explorer | GridPanel > Update > AutoSave
    By r_honey in forum Open Discussions
    Replies: 3
    Last Post: Apr 29, 2010, 5:12 AM

Tags for this Thread

Posting Permissions