Hi
I have the following case
I have a master detail object, in this object I populate the details with a SimpleAction button. the details generate ok , but I can see them in screen. for that I have to close the screen and open it again, how can I refresh de detail part of the screen after I populate it with the simple acction?
Here below is the code I use
Private Sub SimpleAction1_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles SimpleAction1.Execute
Dim startdate As Date
Dim enddate As Date
Dim p As Promotions.planilla
p = CType(View.SelectedObjects(0), Promotions.planilla)
startdate = CType(View.SelectedObjects(0), Promotions.planilla).InicioFecha
enddate = CType(View.SelectedObjects(0), Promotions.planilla).FinFecha
Dim XpoSession As Session = View.ObjectSpace.Session
' Dim criteria As New DevExpress.Data.Filtering.BinaryOperator
Dim Eventos As New XPCollection(XpoSession, GetType(Promotions.Evento), CriteriaOperator.Parse("[FechaEvento] >= #" + startdate + "# AND [FechaEvento] <=#" + enddate + "# AND [Status] = 1"))
Dim DP As Promotions.planillaDetalles
For Each evento As Promotions.Evento In Eventos
For Each detalle As Promotions.EventoDetallePromotores In evento.Promotores
DP = New Promotions.planillaDetalles(XpoSession)
DP.Planilla = p.This
DP.Detalle = evento.NombreEvento + " - " + evento.FechaEvento
DP.Promotor = detalle.Promotor
DP.ValorHoras = evento.ValorHora
DP.Extendido = evento.ValorHora * evento.HorasTrabajadas
DP.Horas = evento.HorasTrabajadas
DP.Save()
Next
evento.Status = Promotions.TiposDeStatus.Inactivo
evento.Save()
Next
DP = Nothing
Dim OtrosIngresos As New XPCollection(XpoSession, GetType(Promotions.OtrosIngresosEgresos), CriteriaOperator.Parse("[Fecha] >= #" + startdate + "# AND [Fecha] <=#" + enddate + "# AND [Status] = 1"))
For Each IngresoGasto As Promotions.OtrosIngresosEgresos In OtrosIngresos
DP = New Promotions.planillaDetalles(XpoSession)
DP.Planilla = p.This
DP.Detalle = IngresoGasto.Concepto + " - " + IngresoGasto.Fecha
DP.Promotor = IngresoGasto.Promotor
DP.ValorHoras = 0
DP.Extendido = IIf(IngresoGasto.TipoDeValor = Promotions.TiposDeValor.Ingreso, IngresoGasto.Valor, IngresoGasto.Valor * -1)
DP.Horas = 0
DP.Save()
IngresoGasto.Status = Promotions.TiposDeStatus.Inactivo
IngresoGasto.Save()
Next
XpoSession.CommitTransaction()
End Sub
Hi Carlos,
Thank you for the report, but it appears that we need some additional help from you: could you provide us with the entire project, or a test sample illustrating your problem, because the information you provided doesn't allow us to understand your task completely.
Your own screenshot or specific explanation can clarify the following things "…in this object I populate the details" and "…detail part of the screen" as well.
This information is necessary to find an accessible solution to your problem.
Thanks
Den
Hi Dean
Here I send you an sample project and a screenshot. feel free to ask anyother detail
Hi Carlos,
I suggest you populate the planillaDetalles collection via the CollectionSource property of the planillaDetalles_ListView view, instead.
In this instance the generated objects will be added immediately.
In my example, the Details collection will be populated based on a range of dates, specified by a user in master detail view, after clicking the "Create details" action. See the following code:
Partial Public Class ViewController1 Inherits ViewController Private Shared master As Master Public Sub New() InitializeComponent() RegisterActions(components) End Sub Protected Overloads Overrides Sub OnActivated() MyBase.OnActivated() simpleAction1.SetActiveByKey("", View.ObjectType Is GetType(Detail) AndAlso TypeOf View Is ListView) If View.IsRoot AndAlso View.ObjectType Is GetType(Master) AndAlso TypeOf View Is DetailView Then master = TryCast(View.CurrentObject, Master) End If End Sub Private Sub simpleAction1_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs) Handles simpleAction1.Execute Dim listView As ListView = TryCast(View, ListView) Dim details As XPCollection(Of Detail) = New XPCollection(Of Detail)(View.ObjectSpace.Session, CriteriaOperator.Parse("[Date]>= ? AND [Date]<=?", master.Start, master.Finish)) TryCast(listView.CollectionSource.Collection, XPCollection(Of Detail)).AddRange(details) End Sub End Class
I have included a complete sample illustrating this approach in the attachment. Please let me know if it helps you.
Besides, if you want to refresh the corresponding view, then you can use the View's Refresh method:
Please refer to the following help topics in our documentation:
XAF > Reference > DevExpress.ExpressApp > View Class > View Methods > Refresh Method
XAF > Reference > DevExpress.ExpressApp > ListView Class > ListView Properties > CollectionSource Property
It may be helpful for you.
Also, you can handle the ObjectSpace.Committed event and invoke the Refresh method there. It will allow you to update the view when saving an object.
Otherwise, if my solution is not suitable, please try to isolate the problem in a small test project. Also, provide us with step-by-step instructions on how to reproduce it, because I could not reproduce the "the details generate ok , but I can see them in screen. for that I have to close the screen and open it again" according the information you sent.
P.S.
>> Hi Dean
BTW, Please call me Den, not Dean
Thanks
Den