Page 1 of 1

How do I Increase decimal places in Inventory custom field

PostPosted: Fri Dec 04, 2015 10:22 pm
by indikad
Trying to Increase the custom field decimal places in a inventory custom field of float type to 4 from the default 2 but my code below does not work

any help ?

Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      If TypeOf JiwaForm Is JiwaInventoryUI.InventoryMaintenanceForm  Then
         Dim oInvetForm As JiwaInventoryUI.InventoryMaintenanceForm= DirectCast(JiwaForm, JiwaInventoryUI.InventoryMaintenanceForm )
         ' Store a reference to this sales order form in the business logic
         Dim formReference As New JiwaApplication.BusinessLogic.GenericObjectItem
         formReference.RecID = "InventoryForm"
         formReference.Object = oInvetForm         
         oInvetForm.Inventory.GenericObjectCollection.Add(formReference)                     
         AddHandler oInvetForm.Inventory.ReadEnd , AddressOf InventoryReadEnd
         'AddHandler oInvetForm.Inventory.CreateEnd , AddressOf InventoryCreateEnd      
      End If
    End Sub
   Private Sub InventoryReadEnd( ByVal sender As Object ,ByVal  e As System.EventArgs  )      
      Dim oInvent  As JiwaInventory.Inventory   = DirectCast(sender, JiwaInventory.Inventory )
      Dim oInventForm As JiwaInventoryUI.InventoryMaintenanceForm  = DirectCast( oInvent.GenericObjectCollection("InventoryForm").Object, JiwaInventoryUI.InventoryMaintenanceForm )
      'oInventForm.grdCustomFields.GridDecimalPlaces("Sample float", -1, 4, -1)
      oInventForm.CustomFieldsGrid.GridDecimalPlaces ("Sample float", -1, 4, -1)      
   End Sub



Re: How do I Increase decimal places in Inventory custom fie  Topic is solved

PostPosted: Sat Dec 05, 2015 10:06 am
by Mike.Sheen
You should use the FormatCell method in the CustomFieldPlugin class instead... here's an excerpt from a tile calculator plugin I wrote which sets the decimal places on an inventory custom field named "TileSize":

Code: Select all
Public Class CustomFieldPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaCustomFieldPlugin

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

    Public Sub FormatCell(ByVal BusinessLogicHost As JiwaApplication.IJiwaBusinessLogic, ByVal GridObject As JiwaApplication.Controls.JiwaGrid, ByVal FormObject As JiwaApplication.IJiwaForm, ByVal Col As Integer, ByVal Row As Integer, ByVal HostObject As JiwaApplication.IJiwaCustomFieldValues, ByVal CustomField As JiwaApplication.CustomFields.CustomField, ByVal CustomFieldValue As JiwaApplication.CustomFields.CustomFieldValue) Implements JiwaApplication.IJiwaCustomFieldPlugin.FormatCell
      If TypeOf FormObject Is JiwaInventoryUI.InventoryMaintenanceForm Then
         If CustomField.PluginCustomField.Name = "TileSize" Then
            ' Set decimal places to 6
            If GridObject.ActiveSheet.Cells(Row, Col).CellType Is Nothing Then
               GridObject.ActiveSheet.Cells(Row, Col).CellType = New FarPoint.Win.Spread.CellType.NumberCellType
            End If
            DirectCast(GridObject.ActiveSheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.NumberCellType).DecimalPlaces = 6
              End If
      End If
    End Sub

    Public Sub ReadData(ByVal BusinessLogicHost As JiwaApplication.IJiwaBusinessLogic, ByVal GridObject As JiwaApplication.Controls.JiwaGrid, ByVal FormObject As JiwaApplication.IJiwaForm, ByVal Row As Integer, ByVal HostObject As JiwaApplication.IJiwaCustomFieldValues, ByVal CustomField As JiwaApplication.CustomFields.CustomField, ByVal CustomFieldValue As JiwaApplication.CustomFields.CustomFieldValue) Implements JiwaApplication.IJiwaCustomFieldPlugin.ReadData
    End Sub

    Public Sub ButtonClicked(ByVal BusinessLogicHost As JiwaApplication.IJiwaBusinessLogic, ByVal GridObject As JiwaApplication.Controls.JiwaGrid, ByVal FormObject As JiwaApplication.IJiwaForm, ByVal Col As Integer, ByVal Row As Integer, ByVal HostObject As JiwaApplication.IJiwaCustomFieldValues, ByVal CustomField As JiwaApplication.CustomFields.CustomField, ByVal CustomFieldValue As JiwaApplication.CustomFields.CustomFieldValue) Implements JiwaApplication.IJiwaCustomFieldPlugin.ButtonClicked
    End Sub


Re: How do I Increase decimal places in Inventory custom fie

PostPosted: Mon Dec 07, 2015 10:51 am
by indikad
Thanks This works -
noting that the code needed to be in the Custom field plugin itself. ( it did not work when I used a separate plugin )

All good.