Editing GridPanel attached to a SQLDatasource

  1. #1

    [1.0] Editing GridPanel attached to a SQLDatasource

    Can anyone give me an example of how to save changes made in a GridPanel (preferably using the Editor plug in https://examples1.ext.net/#/GridPane...ins/RowEditor/) via a SQLDatasource? I have spent hours wandering through the examples and the forums and have not found a semi-complete example that I can follow.

    Ext.Net seems like a wonderful tool (and from experience I know its potential for accessing and displaying information on a page) but it seems to have an incredibility steep learning curve when it comes to updating data in a database. I would appreciate any help in this.

    Thank in advance.

    Nathan Wheeler
    Last edited by tnwheeler; Aug 30, 2010 at 7:18 PM. Reason: Added "[1.0]" flag to Title.
  2. #2
    https://examples2.ext.net/GridPanel/...SqlDataSource/

    The above example gives you how to connect the GridPanel with a SqlDataSource which you can extend with insert/update/delete commands on the sqldatasource, add autosave="True" on the ext:store, and add an editor then you should have a functional grid with field by field saving.

    It should look something like this if you have a single table with an identity column and a string ie. varchar column.

           <asp:SqlDataSource 
                ID="SqlDataSource1" 
                runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT [EmployeeID], [EmpName] FROM [Employees]"
                InsertCommand="INSERT INTO [Employees] ([EmpName]) VALUES (@EmpName)"
                UpdateCommand="UPDATE [Employees] SET [EmpName]=@EmpName WHERE [EmployeeID]=@EmployeeID"
                DeleteCommand="DELETE [Employees] WHERE [EmployeeID]=@EmployeeID">
                <DeleteParameters>
                    <asp:Parameter Name="EmployeeID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="EmpName" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="EmployeeID" Type="Int32" />
                    <asp:Parameter Name="EmpName" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
            
            <ext:GridPanel 
                runat="server" 
                Title="Employee Names"
                Frame="true" 
                Height="600">
                <Store>
                    <ext:Store runat="server" DataSourceID="SqlDataSource1" autosave="true">
                        <Reader>
                            <ext:JsonReader IDProperty="EmployeeID">
                                <Fields>
                                    <ext:RecordField Name="EmployeeID" />
                                    <ext:RecordField Name="Name" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column DataIndex="EmployeeID" Header="EmployeeID" Editable="false">
                        </ext:Column>
                        <ext:Column DataIndex="EmpName" Header="Full Name" Width="150">
                            <Editor>
                                <ext:TextField runat="server" MaxLength="100">
                                </ext:TextField>
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" />
                </SelectionModel>
            </ext:GridPanel>
    https://examples2.ext.net/GridPanel/...SqlDataSource/
    Or this example has a save button.
  3. #3
    Thanks this at least got me working in the right direction.

Similar Threads

  1. Replies: 2
    Last Post: Jul 02, 2012, 6:15 PM
  2. [CLOSED] Editing cell of gridPanel
    By supera in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: May 23, 2012, 12:47 PM
  3. How to change GridPanel editing row backcolor
    By kakagu in forum 1.x Help
    Replies: 0
    Last Post: May 08, 2012, 7:06 AM
  4. Cancel insertion or editing of gridpanel
    By andrefreitasjr in forum 1.x Help
    Replies: 4
    Last Post: May 31, 2011, 1:50 AM
  5. Replies: 0
    Last Post: Apr 14, 2011, 7:10 AM

Tags for this Thread

Posting Permissions