[CLOSED] DirectEvent Store.getChangedData only passes modified records

  1. #1

    [CLOSED] DirectEvent Store.getChangedData only passes modified records

    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?
    Last edited by Baidaly; Dec 02, 2013 at 9:45 PM. Reason: [CLOSED]
  2. #2
    Hello!

    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.
  3. #3
    Ok, for saving item I use:

        Protected Sub SaveItem(ByVal sender As Object, ByVal args As DirectEventArgs)
            Try
                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)
                Else
                    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"})
                ItemWindow.Close()
            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")
            Try
                BindDataStore2()
                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">
                                    <DirectEvents>
                                        <Click OnEvent="SaveDocument">
                                            <ExtraParams>
                                                 <extnet:Parameter Name="items" Value="#{Store2}.getChangedData()" Mode="Raw" Encode="true" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </extnet:Button>
  4. #4
    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.
  5. #5
    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.
  6. #6
    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.

Similar Threads

  1. Replies: 0
    Last Post: May 14, 2013, 10:05 AM
  2. Replies: 5
    Last Post: Jun 14, 2011, 11:47 AM
  3. [CLOSED] Modified records in store get purged prior to BeforeLoad event
    By Mark.Cooke in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 20, 2010, 7:08 PM
  4. Replies: 3
    Last Post: Mar 29, 2010, 9:10 AM
  5. [CLOSED] Added Records don't show up as modified
    By Dave.Sanders in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 21, 2008, 6:54 AM

Tags for this Thread

Posting Permissions