View Full Version : [CLOSED] DirectEvent Store.getChangedData only passes modified records

Dec 01, 2013, 9:23 AM
Hi, I am trying to develop a master detail application using a save button to commit changes to database at once. I have an items store and every time the user wants to create an item I use Store.Add method on server side to do it. On save document button I have a DirectEvent in which I pass modified records back to server using Store.getChangedData. Problem is I get only modified records but not the new inserted ones. Is it there any way to pass everything from store, inserted, deleted and modified records on a DirectEvent?

Dec 01, 2013, 9:08 PM

It is difficult to say what's wrong without a sample to reproduce. However, please take a look at this example: https://examples2.ext.net/#/GridPanel/Update/Batch/

In this sample this getChangedData method works fine.

Dec 01, 2013, 9:39 PM
Ok, for saving item I use:

Protected Sub SaveItem(ByVal sender As Object, ByVal args As DirectEventArgs)
If fpart_code.Text = "" Then
Throw New Exception("Codigo de producto es requerido")
End If
If fuom_code.Text = "" Then
Throw New Exception("Unidad de medida es requerido")
End If
If fuom_qty.Text = "" Then
Throw New Exception("Cantidad es requerida")
End If
If ftaxedcustprice_amt.Text = "" Then
Throw New Exception("Precio para el cliente es requerido")
End If
If fline_num.Text <> "" Then
Dim sdr As Ext.Net.ModelProxy
sdr = Store2.GetById(PsaConvert.ObjToInt(fline_num.Text) )
sdr.Set("PART_CODE", fpart_code.Text)
sdr.Set("DESC_TEXT", fpart_desc.Text)
sdr.Set("SERIAL_CODE", fserial_code.Text)
sdr.Set("CF_TAXEDCUST_PRICE_AMT", ftaxedcustprice_amt.Text)
sdr.Set("UOM_CODE", fuom_code.Text)
sdr.Set("UOM_QTY", fuom_qty.Text)
sdr.Set("DISC_CODE", fdisc_code.Text)
sdr.Set("DISC_PER", fdisc_per.Text)
sdr.Set("CF_TAXEDUNIT_PRICE_AMT", ftaxedunitprice_amt.Text)
Dim sql As String = "select max(line_num) from tecserdetl where cmpy_code = '%1' and order_num = %2"
sql = sql.Replace("%1", PsaSession.Cmpy)
sql = sql.Replace("%2", KeyCode)
Dim o As Integer = PsaConvert.ObjToInt(PsaData.ExecuteScalar(sql)) + 1
Store2.Add(New With {.LINE_NUM = o, _
.PART_CODE = fpart_code.Text, _
.DESC_TEXT = fpart_desc.Text, _
.SERIAL_CODE = fserial_code.Text, _
.UOM_CODE = fuom_code.Text, _
.UOM_QTY = fuom_qty.Text, _
.DISC_CODE = fdisc_code.Text, _
.DISC_PER = fdisc_per.Text, _
.CF_TAXEDCUST_PRICE_AMT = ftaxedcustprice_amt.Text, _
.CF_TAXEDUNIT_PRICE_AMT = ftaxedunitprice_amt.Text _
End If
Notification.Show(New NotificationConfig With {.Title = "Item", .Html = "Item salvado"})
Catch ex As Exception
args.Success = False
args.ErrorMessage = ex.Message
End Try
End Sub

for saving document use:

Protected Sub SaveDocument(ByVal sender As Object, ByVal args As DirectEventArgs)
Dim items As String = args.ExtraParams("items")
Notification.Show(New NotificationConfig With {.Title = "Documento", .Html = "Documento salvado"})
Catch ex As Exception
args.Success = False
args.ErrorMessage = ex.Message
End Try
End Sub

SaveDocument event is triggered by

<extnet:Button ID="btnSave" runat="server" Text="Salvar" Icon="DatabaseSave">
<Click OnEvent="SaveDocument">
<extnet:Parameter Name="items" Value="#{Store2}.getChangedData()" Mode="Raw" Encode="true" />

Dec 02, 2013, 4:44 AM
Please clarify are the new records go to the Save handler as updated ones? Or does it not go at all?

One guess - when you add a new record, you set up its IDProperty ModelField, therefore it is not treated as a new one.

Dec 02, 2013, 8:38 AM
Yes I do set up the IDProperty ModelField so later on if the user wants to change the row again before saving document I can save back data to store using IDProperty. Maybe it would be a better idea to use recordId. Let me try the modification and be back with you.

Dec 02, 2013, 9:15 PM
I tried what you mentioned and fixed the problem. I am now getting all the updated, inserted and deleted rows.
You can close the case now.