Sales Order Line custom field - display as decimal

Posted:
Fri Oct 02, 2015 12:01 pm
by DannyC
I have a sales order line custom field which is configured as a Float field.
When displayed on the grid, there are no decimals displayed.
How can I format the display of the custom field to show 2 decimal places?
Thanks
Danny
Re: Sales Order Line custom field - display as decimal 

Posted:
Tue Oct 20, 2015 11:43 am
by Scott.Pearce
You need to format it in the FormatCell method of the LineCustomFieldPlugin class in your plugin.
- Code: Select all
Public Class LineCustomFieldPlugin
Inherits System.MarshalByRefObject
Implements JiwaApplication.IJiwaLineCustomFieldPlugin
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 HostItem As JiwaApplication.IJiwaLineCustomFieldValues, ByVal CustomField As JiwaApplication.CustomFields.CustomField, ByVal CustomFieldValue As JiwaApplication.CustomFields.CustomFieldValue) Implements JiwaApplication.IJiwaLineCustomFieldPlugin.FormatCell
If customfield.PluginCustomField.Name = "MyCustomField" Then
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 = 2
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 HostItem As JiwaApplication.IJiwaLineCustomFieldValues, ByVal CustomField As JiwaApplication.CustomFields.CustomField, ByVal CustomFieldValue As JiwaApplication.CustomFields.CustomFieldValue) Implements JiwaApplication.IJiwaLineCustomFieldPlugin.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 HostItem As JiwaApplication.IJiwaLineCustomFieldValues, ByVal CustomField As JiwaApplication.CustomFields.CustomField, ByVal CustomFieldValue As JiwaApplication.CustomFields.CustomFieldValue) Implements JiwaApplication.IJiwaLineCustomFieldPlugin.ButtonClicked
End Sub
End Class