Page 1 of 1

Sales Order Line Custom field combo not displaying

PostPosted: Tue Dec 01, 2015 6:16 pm
by indikad
I am trying to add ( or import from legacy 6513 ) a Line custom field that is of combo type to the sales order lines
however the combo box does not respond to my clicks ( does not display any values )

see my sample code below
the same code is for a new combo box , but the requirement is for a imported one from 6513 ( I have already moved it to my new plugin from Legacy )
interestingly the grid manager shows the custom field name as PluginName.fieldname

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 CustomField.PluginCustomField.Name = "ALL_CUSTOM_FIELDS.TestCombo" Then ' -- so lines
   If CustomField.PluginCustomField.Name = "TestCombo" Then ' -- so lines
            Dim MyDisplayItems As New List(Of String)
            Dim MyUnderlyingValues As New List(Of String)

            MyDisplayItems.Add("One des")
            MyDisplayItems.Add("Two des")
            MyDisplayItems.Add("Three des ")         
         
      
            MyUnderlyingValues.Add("One")
            MyUnderlyingValues.Add("Two")
            MyUnderlyingValues.Add("Three")      
         

            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData
            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).Items = MyDisplayItems.ToArray
            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).ItemData = MyUnderlyingValues.ToArray
        End If


            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData
            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).Items = MyDisplayItems.ToArray
            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).ItemData = MyUnderlyingValues.ToArray
        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

End Class

Re: Sales Order Line Custom field combo not displaying  Topic is solved

PostPosted: Wed Dec 02, 2015 8:26 am
by Scott.Pearce
You're putting your code in the "LineCustomFieldPlugin" class right? The sample you provided is for "CustomFieldPlugin".

Re: Sales Order Line Custom field combo not displaying

PostPosted: Wed Dec 02, 2015 9:51 am
by indikad
Scott.Pearce wrote:You're putting your code in the "LineCustomFieldPlugin" class right? The sample you provided is for "CustomFieldPlugin".


hold on! I think that could be it. I will check and get back.

Re: Sales Order Line Custom field combo not displaying

PostPosted: Wed Dec 02, 2015 9:52 am
by Scott.Pearce
Doh!

Re: Sales Order Line Custom field combo not displaying

PostPosted: Wed Dec 02, 2015 10:03 am
by indikad
Scott -

Moving the code to "LineCustomFieldPlugin" improved a bit - however the code below seems need a change to address line custom fields I think but I dont know how to. The code as is will give me an error - Object Reference Not set to an instance of an Object Module:Format Cell

Code: Select all

            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData
            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).Items = MyDisplayItems.ToArray
            DirectCast(GridObject.Activesheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.ComboBoxCellType).ItemData = MyUnderlyingValues.ToArray

Re: Sales Order Line Custom field combo not displaying

PostPosted: Wed Dec 02, 2015 10:21 am
by Scott.Pearce
This is because of the way the grid assigns cell types. When creating a grid, a cell type is assigned to the column. This does *not* imply, however, that the individual cells also have this cell type - they will use the cell type of the column they belong to UNLESS the celltype of the *CELL* has been explicitly set, in which case the cell uses that. This allows you do do things like make every cell in a column have the same set of say, combo-box items, EXCEPT for a cell here and a cell there where the celltype is overriden.

In any case, you need to do this before your 3 "DirectCast..." lines:

Code: Select all
If GridObject.Activesheet.Cells(Row, Col).CellType Is Nothing Then
    GridObject.Activesheet.Cells(Row, Col).CellType = GridObject.Activesheet.Columns(Col).CellType
End If


See what the code above is doing? It's explicitly setting the cell's type to that of it's owning column, if required.

Re: Sales Order Line Custom field combo not displaying

PostPosted: Wed Dec 02, 2015 10:44 am
by indikad
looks good now - Thanks Scott for the prompt reply.