[FIXED] [V0.7] Deleting rows with the ObjectDataSource

  1. #1

    [FIXED] [V0.7] Deleting rows with the ObjectDataSource

    Hello,

    I try to delete rows when using ObjectDataSource, but I receive the following error under IE: 'Microsoft JScript runtime error: Object doesn't support this property or method'. My configuration is similar to your example GridPanel/DataSource Controls/Paging & Sorting. I have modified the sample to illustrate the problem. The steps to replicate this are:
    - select a row on the grid
    - click the Delete button
    - click the Save button

    The JavaScript error should show up.

    How can I make this work?


    Default.aspx:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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 id="Head1" runat="server">
        <title>Coolite Toolkit - GridPanel with ObjectDataSource</title>
        <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
    
        <script runat="server">
            protected void Store1_RefreshData( object sender, StoreRefreshDataEventArgs e )
            {
                ObjectDataSource1.SelectParameters["start"].DefaultValue = e.Start.ToString();
                ObjectDataSource1.SelectParameters["limit"].DefaultValue = e.Limit.ToString();
                ObjectDataSource1.SelectParameters["sort"].DefaultValue = e.Sort;
                ObjectDataSource1.SelectParameters["dir"].DefaultValue = e.Dir.ToString();
    
                Store1.DataBind();
            }
    
            protected void ObjectDataSource1_Selected( object sender, ObjectDataSourceStatusEventArgs e )
            {
                ( this.Store1.Proxy[0] as DataSourceProxy ).TotalCount = (int) e.OutputParameters["count"];
            }
        </script>
    
        <style type="text/css">
            .x-grid3-td-fullName .x-grid3-cell-inner
            {
                font-family: tahoma, verdana;
                display: block;
                font-weight: normal;
                font-style: normal;
                color: #385F95;
                white-space: normal;
            }
            .x-grid3-row-body p
            {
                margin: 5px 5px 10px 5px !important;
                width: 99%;
                color: Gray;
            }
        </style>
    
        <script type="text/javascript">
            var fullName = function(value, metadata, record, rowIndex, colIndex, store)
            {
                return '' + record.data.LastName + ' ' + record.data.FirstName + '';
            };
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OnSelected="ObjectDataSource1_Selected"
            SelectMethod="GetEmployeesFilter" TypeName="Coolite.Examples.Code.Northwind.Employee"
            DeleteMethod="DeleteEmployee">
            <SelectParameters>
                <asp:Parameter Name="start" Type="Int32" />
                <asp:Parameter Name="limit" Type="Int32" />
                <asp:Parameter Name="sort" />
                <asp:Parameter Name="dir" />
                <asp:Parameter Name="count" Direction="Output" Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="EmployeeID" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <ext:Store ID="Store1" runat="server" AutoLoad="true" RemoteSort="true" DataSourceID="ObjectDataSource1"
            OnRefreshData="Store1_RefreshData">
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="={0}" />
                <ext:Parameter Name="limit" Value="={3}" />
            </AutoLoadParams>
            <Proxy>
                <ext:DataSourceProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader ReaderID="EmployeeID">
                    <Fields>
                        <ext:RecordField Name="FirstName" />
                        <ext:RecordField Name="LastName" />
                        <ext:RecordField Name="Title" />
                        <ext:RecordField Name="TitleOfCourtesy" />
                        <ext:RecordField Name="BirthDate" Type="Date" />
                        <ext:RecordField Name="HireDate" Type="Date" />
                        <ext:RecordField Name="Address" />
                        <ext:RecordField Name="City" />
                        <ext:RecordField Name="Region" />
                        <ext:RecordField Name="PostalCode" />
                        <ext:RecordField Name="Country" />
                        <ext:RecordField Name="HomePhone" />
                        <ext:RecordField Name="Extension" />
                        <ext:RecordField Name="Notes" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel runat="server" ID="GridPanel1" Title="Employees" Frame="true" StoreID="Store1"
            Height="300">
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column ColumnID="fullName" Header="Full Name" Width="150" DataIndex="LastName">
                        <Renderer Fn="fullName" />
                    </ext:Column>
                    <ext:Column DataIndex="Title" Header="Title" Width="150" />
                    <ext:Column DataIndex="TitleOfCourtesy" Header="Title Of Courtesy" Width="150" />
                    <ext:Column DataIndex="BirthDate" Header="BirthDate" Width="110">
                        <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
                    </ext:Column>
                    <ext:Column DataIndex="HireDate" Header="HireDate" Width="110">
                        <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
                    </ext:Column>
                    <ext:Column DataIndex="Address" Header="Address" Width="150" />
                    <ext:Column DataIndex="City" Header="City" Width="100" />
                    <ext:Column DataIndex="Region" Header="Region" Width="100" />
                    <ext:Column DataIndex="PostalCode" Header="PostalCode" Width="100" />
                    <ext:Column DataIndex="Country" Header="Country" Width="100" />
                    <ext:Column DataIndex="HomePhone" Header="HomePhone" Width="150" />
                    <ext:Column DataIndex="Extension" Header="Extension" Width="100" />
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView runat="server" EnableRowBody="true">
                    <GetRowClass Handler="rowParams.body = '<p>'+record.data.Notes+'</p>'; return 'x-grid3-row-expanded';" />
                </ext:GridView>
            </View>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="3" StoreID="Store1"
                    DisplayInfo="true" DisplayMsg="Displaying employees {0} - {1} of {2}" EmptyMsg="No employees to display" />
            </BottomBar>
            <LoadMask ShowMask="true" />
        </ext:GridPanel>
        <ext:Button ID="btnDelete" runat="server" Text="Delete" AutoPostBack="false" Icon="Delete">
            <Listeners>
                <Click Handler="#{GridPanel1}.deleteSelected();" />
            </Listeners>
        </ext:Button>
        <ext:Button ID="Button3" runat="server" Text="Save" AutoPostBack="false" Icon="Disk">
            <Listeners>
                <Click Handler="#{GridPanel1}.save();" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
    This also requires adding the following method to the Employee class:
    public static void DeleteEmployee(int EmployeeID)
            {
                NorthwindDataContext db = new NorthwindDataContext();
                var empl = db.Employees.FirstOrDefault( e => e.EmployeeID == EmployeeID );
                if ( empl != null )
                {
                    db.Employees.DeleteOnSubmit( empl );
                    //db.SubmitChanges(); // all the related rows should be deleted before calling this method
                }
            }
    Regards,
    Tadeusz
  2. #2

    RE: [FIXED] [V0.7] Deleting rows with the ObjectDataSource

    Hi Tadeusz,

    We found a defect. The fix has been committed to the SVN.
    Please update and confirm that all works correct for you.

    Thank you for bug pointing.


    Vladimir Shcheglov
    Sr. Developer
  3. #3

    RE: [FIXED] [V0.7] Deleting rows with the ObjectDataSource

    Hi Vladimir,

    This has fixed the bug. Thank you.

    Regards,
    Tadeusz

Similar Threads

  1. Deleting a row from a GridPanel techniques.
    By chearner in forum 1.x Help
    Replies: 3
    Last Post: Nov 14, 2011, 7:58 PM
  2. [CLOSED] deleting item in combo box
    By speedstepmem2 in forum 1.x Premium Help
    Replies: 2
    Last Post: Mar 09, 2011, 6:03 PM
  3. Deleting row in GridPanel
    By HexElffilter in forum 1.x Help
    Replies: 9
    Last Post: Feb 25, 2011, 4:00 PM
  4. Deleting record from Grid is not working
    By latif in forum 1.x Help
    Replies: 1
    Last Post: Dec 25, 2009, 12:18 PM
  5. GridPanel Store and Deleting Records
    By Timothy in forum 1.x Premium Help
    Replies: 8
    Last Post: Sep 07, 2008, 12:18 PM

Posting Permissions