Dec 20, 2011, 5:23 PM
[1.2] Postback on null values with autosave
Here is another variant of the postback issue. When you tab through the cells on a gridpanel with autosave, the cells with a null value will trigger an update of the database. But the cells with data will not trigger any update of the database and should not as expected since the data did not change.
Steps to reproduce
1) Create the sql table for the gridpanel (see sql script below)
2) Add a couple of records with first name only
3) Load the gridpanel below
4) Click on the first row's first name
5) Begin to tab through the cells
6) The Last Name cells will trigger the database update/Autosave
Steps to reproduce
1) Create the sql table for the gridpanel (see sql script below)
2) Add a couple of records with first name only
3) Load the gridpanel below
4) Click on the first row's first name
5) Begin to tab through the cells
6) The Last Name cells will trigger the database update/Autosave
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Your_ApplicationConnectionString %>"
SelectCommand="
SELECT
ID_Person,
NM_First,
NM_Last,
DT_Modified
FROM
[HSA_Person]"
UpdateCommand="
UPDATE
[HSA_Person]
SET
[NM_First] = @NM_First,
[NM_Last] = @NM_Last,
DT_Modified = Getdate()
WHERE
[ID_Person] = @ID_Person"
>
<UpdateParameters>
<asp:Parameter Name="ID_Person" Type="Int32" />
<asp:Parameter Name="NM_First" Type="String" />
<asp:Parameter Name="NM_Last" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<ext:GridPanel ID="View1" Title="Listing" runat="server" Frame="true" Border="true" ColumnLines="True" height="220" width="450">
<Store>
<ext:Store ID="Store1" runat="server" DataSourceID="SqlDataSource1" AutoSave="True">
<Reader>
<ext:JsonReader IDProperty="ID_Person">
<Fields>
<ext:RecordField Name="ID_Person" SortType="AsInt" />
<ext:RecordField Name="NM_First" SortType="AsText" />
<ext:RecordField Name="NM_Last" SortType="AsText" />
<ext:RecordField Name="DT_Modified" SortType="AsDate" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column DataIndex="ID_Person" Header="ID" Width="50" Editable="False">
</ext:Column>
<ext:Column DataIndex="NM_First" Header="First Name" Tooltip="First Name" Width="100">
<Editor>
<ext:TextField ID="TextField1" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
<ext:Column DataIndex="NM_Last" Header="Last Name" Tooltip="Last Name" Width="100">
<Editor>
<ext:TextField ID="TextField2" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
<ext:DateColumn DataIndex="DT_Modified" Header="Last Updated" Format="MM/dd/yyyy HH:mm:ss" Width="150">
</ext:DateColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
</ext:GridPanel>
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[HSA_Person](
[ID_Person] [int] IDENTITY(1,1) NOT NULL,
[NM_First] [varchar](50) NULL,
[NM_Last] [varchar](50) NULL,
[DT_Modified] [datetime] NULL,
CONSTRAINT [PK_HSA_Person] PRIMARY KEY CLUSTERED
(
[ID_Person] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO