Aug 04, 2017, 3:42 PM
[FIXED] [#1526] [4.3.0] Store OnBeforeStoreChanged only fires once on first edit of Gridpanel, all other edits are "stuck" dirty
Hi guys.
Probably a simple fix but I'm having trouble.
I'm trying to add rows dynamically to a Store/Gridpanel and let users edit them with a CellEditing plugin.
The first time they edit the cells, it's fine. The changes are saved. The second cell that is edited, and all subsequent cells, are flagged dirty and stay dirty forever. The Store's OnBeforeStoreChanged event is never fired again.
Below is the sample code. It's very easy to reproduce this issue:
It will remain dirty. All further edits will remain dirty. The OnBeforeStoreChanged DirectEvent will never fire again.
I've tried CommmitChanges on the Store and refreshing the View on the Gridpanel...both with Javascript and with DirectEvents. DirectEvent does nothing, doing it in Javascript on the page does clear the dirty flags but the behavior remains the same.
Any help appreciated,
David
Code to reproduce issue below:
Main Page:
Probably a simple fix but I'm having trouble.
I'm trying to add rows dynamically to a Store/Gridpanel and let users edit them with a CellEditing plugin.
The first time they edit the cells, it's fine. The changes are saved. The second cell that is edited, and all subsequent cells, are flagged dirty and stay dirty forever. The Store's OnBeforeStoreChanged event is never fired again.
Below is the sample code. It's very easy to reproduce this issue:
- Type "5" in the text box at the top and click the "Add/Subtract Lines" Button.
- 5 Lines will be added to the Gridpanel.
- Double click any of the cells to edit them.
- Do any edit you like. Then click off the box.
- Double click a different box and edit it.
It will remain dirty. All further edits will remain dirty. The OnBeforeStoreChanged DirectEvent will never fire again.
I've tried CommmitChanges on the Store and refreshing the View on the Gridpanel...both with Javascript and with DirectEvents. DirectEvent does nothing, doing it in Javascript on the page does clear the dirty flags but the behavior remains the same.
Any help appreciated,
David
Code to reproduce issue below:
Main Page:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test.aspx.vb" Inherits="SupplierPortalV2.Test1" %>
<!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">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<title>Ext.Net Test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:Viewport runat="server" >
<Items>
<ext:GridPanel runat="server" ID="grdMain" AutoDataBind="true" >
<Store>
<ext:Store runat="server" ID="storMain" OnBeforeStoreChanged="handleChanges" AutoSync="true" >
<Model>
<ext:Model runat="server" >
<Fields>
<ext:ModelField Name="idProperty" Type="Int" />
<ext:ModelField Name="item1" Type="String" />
<ext:ModelField Name="item2" Type="String" />
<ext:ModelField Name="item3" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<TopBar>
<ext:Toolbar runat="server" >
<Items>
<ext:ToolbarFill runat="server" />
<ext:NumberField runat="server" ID="nmbLines" FieldLabel="# of Lines" />
<ext:ToolbarSpacer Width="10" />
<ext:Button runat="server" Text="Add/Subtract Lines" >
<DirectEvents>
<Click OnEvent="buildRows" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel>
<Columns>
<ext:Column runat="server" DataIndex="idProperty" />
<ext:Column runat="server" DataIndex="item1" >
<Editor>
<ext:TextField runat="server" ID="editItem1" />
</Editor>
</ext:Column>
<ext:Column runat="server" DataIndex="item2" >
<Editor>
<ext:TextField runat="server" ID="editItem2" />
</Editor>
</ext:Column>
<ext:Column runat="server" DataIndex="item3" >
<Editor>
<ext:TextField runat="server" ID="editItem3" />
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing runat="server" >
</ext:CellEditing>
</Plugins>
</ext:GridPanel>
</Items>
</ext:Viewport>
</div>
</form>
</body>
</html>
Code behind:Imports Ext.Net
Public Class testClass
Public Property idProperty As Integer
Public Property item1 As String
Public Property item2 As String
Public Property item3 As String
Sub New(ByVal idProperty As Integer, ByVal item1 As String, ByVal item2 As String, ByVal item3 As String)
Me.idProperty = idProperty
Me.item1 = item1
Me.item2 = item2
Me.item3 = item3
End Sub
End Class
Public Class Test1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Sub buildRows(ByVal sender As Object, ByVal e As DirectEventArgs)
If Session("lines") Is Nothing Then
Session("lines") = New List(Of testClass)
End If
Dim lineList As List(Of testClass) = Session("lines")
Dim currentRows = lineList.Count
Dim newRows As Integer = nmbLines.Value
If newRows > currentRows Then
For i As Integer = currentRows + 1 To newRows
lineList.Add(New testClass(i, "thing1", "thing2", "thing3"))
Next
ElseIf newRows < currentRows Then
lineList.RemoveRange(newRows, currentRows - newRows)
End If
Session("lines") = lineList
storMain.DataSource = lineList
storMain.DataBind()
grdMain.DataBind()
End Sub
Protected Sub handleChanges(ByVal sender As Object, ByVal e As BeforeStoreChangedEventArgs)
Dim newlines As List(Of testClass) = e.DataHandler.ObjectData(Of testClass)()
If e.Action = StoreAction.Update Then
Dim listToUpdate As List(Of testClass) = Session("lines")
For Each updated As testClass In newlines
For Each l As testClass In listToUpdate
If l.idProperty = updated.idProperty Then
l.item1 = updated.item1
l.item2 = updated.item2
l.item3 = updated.item3
End If
Next
Next
Session("lines") = listToUpdate
storMain.CommitChanges()
grdMain.Refresh()
End If
End Sub
End Class
Last edited by fabricio.murta; Aug 10, 2017 at 10:47 PM.