Almost working - Autosave edits from Grid back to SQL Server

  1. #1

    Almost working - Autosave edits from Grid back to SQL Server

    Hi All,

    I must be missing something simple here. I am testing Ext.Net and as my Hello World I wanted to see how hard it would be to wire up an editable grid. My grid is displayed and editable, and the autosave seems to think it is saving something because the red mod mark disappears after editing, but the database table does not get updated.

    Can anyone see what I might be missing?
    Thanks,
    Dave

    
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <!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></title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:celerantConnectionString %>" 
            SelectCommand="SELECT [EMPLOYEE_ID], [STORE_ID], [LAST_NAME], [FIRST_NAME] FROM [TB_EMPLOYEE] ORDER BY STORE_ID, FIRST_NAME, LAST_NAME">
        </asp:SqlDataSource>
    
        <ext:Window ID="Window1" 
            runat="server" 
            Width="1024"
            Height="750"
            Border="false"
            Closable="false"
            X="100"
            Y="100"
            Plain="true">
            <Items>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <West Collapsible="true" MinWidth="175" Split="true">
                        <ext:Panel ID="Panel1" 
                            runat="server"                             
                            Width="175" 
                            CtCls="west-panel"
                            Title="Navigation" 
                            Collapsed="true"
                            Padding="5"
                            Html="Treeview will go here"
                            />
                    </West>
                    <Center>
                        <ext:GridPanel ID="GridPanel1" runat="server" Height="300" Title="Title" AutoDataBind="True" StripeRows="true">
                            <Store>
                                <ext:Store runat="server" DataSourceID="SqlDataSource1" AutoSave="true" UseIdConfirmation="false" AutoDataBind="true">
                                    <Reader>
                                        <ext:JsonReader IDProperty="EMPLOYEE_ID">
                                            <Fields>
                                                <ext:RecordField Name="STORE_ID" />
                                                <ext:RecordField Name="LAST_NAME" />
                                                <ext:RecordField Name="FIRST_NAME" />
                                            </Fields>
                                        </ext:JsonReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                            <ColumnModel ID="ColumnModel1" runat="server">
                                <Columns>
                                    <ext:Column Header="Store #" Width="30" DataIndex="STORE_ID"/>
                                    <ext:Column Header="First" Width="150" DataIndex="FIRST_NAME">
                                        <Editor>
                                            <ext:TextField runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column Header="Last" Width="150" DataIndex="LAST_NAME">
                                        <Editor>
                                            <ext:TextField runat="server" />
                                        </Editor>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <View>
                                <ext:GridView ID="GridView1" runat="server" EnableRowBody="true">
                                </ext:GridView>
                            </View>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                            </SelectionModel>
                        </ext:GridPanel>
                    </Center>
                </ext:BorderLayout>
            </Items>
        </ext:Window>
    
    </body>
    </html>
  2. #2
    Hi,

    There is no auto update of database. Don't know what way it can be implemented:)

    You have to define .UpdateCommand, .DeleteCommand, etc.

    Please see
    https://examples1.ext.net/#/GridPane...SqlDataSource/

    Also this article can be helpful for you
    http://forums.ext.net/showthread.php?315
  3. #3
    The AutoSave works great once you have the UpdateCommand declared.

    Not sure how I overlooked that :)

    Thanks!
  4. #4
    Hi opendave,

    I re-wrote your <ext:Window> markup to use the .Layout property instead of inner Layout controls. This helps keep the markup a bit tighter and there is a theoretical performance improvement.

    Example

    <ext:Window 
        ID="Window1"
        runat="server"
        Width="1024"
        Height="750"
        Border="false"
        Closable="false"
        X="100"
        Y="100"
        Plain="true"
        Layout="border">
        <Items>
            <ext:Panel 
                ID="Panel1"
                runat="server"                            
                Title="Navigation"
                Region="West"
                Width="175"
                CtCls="west-panel"
                Collapsed="true"
                Collapsible="true" 
                MinWidth="175" 
                Split="true"
                Padding="5"
                Html="Treeview will go here"
                />
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                Height="300" 
                Title="Title" 
                AutoDataBind="True" 
                StripeRows="true"
                Region="Center">
                <Store>
                    <ext:Store 
                        runat="server" 
                        DataSourceID="SqlDataSource1" 
                        AutoSave="true" 
                        UseIdConfirmation="false" 
                        AutoDataBind="true">
                        <Reader>
                            <ext:JsonReader IDProperty="EMPLOYEE_ID">
                                <Fields>
                                    <ext:RecordField Name="STORE_ID" />
                                    <ext:RecordField Name="LAST_NAME" />
                                    <ext:RecordField Name="FIRST_NAME" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Store #" Width="30" DataIndex="STORE_ID"/>
                        <ext:Column Header="First" Width="150" DataIndex="FIRST_NAME">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Last" Width="150" DataIndex="LAST_NAME">
                            <Editor>
                                <ext:TextField runat="server" />
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView runat="server" EnableRowBody="true" />
                </View>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" SingleSelect="true" />
                </SelectionModel>
            </ext:GridPanel>
        </Items>
    </ext:Window>
    Hope this helps.
    Geoffrey McGill
    Founder
  5. #5
    Definitely looks cleaner. My indents look a lot more like the profile of prehistoric man, but other than that I prefer your code.

    Thanks for the suggestion!

Similar Threads

  1. Replies: 3
    Last Post: Nov 01, 2011, 6:15 PM
  2. Replies: 6
    Last Post: Aug 11, 2011, 7:30 PM
  3. Grid with AutoSave sample
    By PetrSnobelt in forum 1.x Help
    Replies: 3
    Last Post: Apr 27, 2011, 11:33 AM
  4. Replies: 2
    Last Post: Apr 04, 2011, 12:32 PM
  5. Replies: 0
    Last Post: Feb 20, 2011, 6:29 PM

Posting Permissions