Page 1 of 1

Where do I trigger grid.lockcolumn

PostPosted: Tue Jul 01, 2014 5:54 pm
by perry
Jiwa 7.0.65

I cannot find which event I should use for locking/unlocking a column in a grid.

For example on purchase order form
Code: Select all
If Not PO Is Nothing AndAlso PO.OrderStatus <> JiwaApplication.Entities.PurchaseOrder.Workflow.Status.Closed Then
                POUI.LinesJiwaGrid.LockColumn(False, "UserDefinedFloat1")
                POUI.LinesJiwaGrid.LockColumn(False, "UserDefinedFloat2")
                POUI.LinesJiwaGrid.LockColumn(False, "UserDefinedFloat3")
            End If


I tried POUI.BusinessLogic.ReadEnd and it doesn't work (there must be other codes to setup UI after ReadEnd is triggered).
Also tried some other events in POUI.LinesJiwaGrid.ActiveSheet and still no luck

There was a GridLineDisplayed event in JIWA6, is there a similar event in JIWA7?

Re: Where do I trigger grid.lockcolumn  Topic is solved

PostPosted: Tue Jul 01, 2014 8:16 pm
by Mike.Sheen
Hi Perry,

There is no GridLineDisplayed event in V7 as there was in V6 - But you can achieve what you want without it. You were on the right track in trying to use the ReadEnd event from the business logic - I've managed to do just this and it works for me.

My code is as follows:

Code: Select all
Imports JiwaFinancials.Jiwa
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Data

Public Class FormPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaFormPlugin
            
   Private _POForm As JiwaPurchaseOrdersUI.MainForm

    Public Overrides Function InitializeLifetimeService() As Object
        ' returning null here will prevent the lease manager
        ' from deleting the Object.
        Return Nothing
    End Function

    Public Sub SetupBeforeHandlers(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.SetupBeforeHandlers
    End Sub

    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      _POForm = DirectCast(JiwaForm, JiwaPurchaseOrdersUI.MainForm)
      AddHandler _POForm.PurchaseOrder.ReadEnd, AddressOf PurchaseOrder_ReadEnd
    End Sub
      
   Public Sub PurchaseOrder_ReadEnd(sender As Object, e As System.EventArgs)
      _POForm.LinesJiwaGrid.LockColumn(False, "UserDefinedFloat1")         
   End Sub
End Class


I'm not sure why your code wasn't working - hard to say without seeing more of how you are adding the handlers. If you were adding your handler in the SetupBeforeHandlers method, rather than the Setup method, then that may explain the behaviour you are seeing. Try the above and let me know how it works out for you.

Mike

Re: Where do I trigger grid.lockcolumn

PostPosted: Wed Jul 02, 2014 12:15 pm
by perry
All good now, thanks.

I was using
Code: Select all
AddHandler POUI.BusinessLogic.ReadEnd, AddressOf POReadEnd

instead of
Code: Select all
AddHandler POUI.PurchaseOrder.ReadEnd, AddressOf POReadEnd


I thought they should behave the same?

Re: Where do I trigger grid.lockcolumn

PostPosted: Wed Jul 02, 2014 12:20 pm
by Mike.Sheen
perry wrote:All good now, thanks.

I was using
Code: Select all
AddHandler POUI.BusinessLogic.ReadEnd, AddressOf POReadEnd

instead of
Code: Select all
AddHandler POUI.PurchaseOrder.ReadEnd, AddressOf POReadEnd


I thought they should behave the same?


Yes, they are the same. If you change my code to use _POForm.BusinessLogic.ReadEnd instead of _POForm.PurchaseOrder.ReadEnd it will still work - I've just tested this and can confirm this.

Re: Where do I trigger grid.lockcolumn

PostPosted: Wed Jul 02, 2014 12:23 pm
by perry
I must've added the handler in SetupBeforeHandlers yesterday then.

Thanks for help.