Page 1 of 1

Add extra date column to Notes grid

PostPosted: Thu Oct 06, 2022 4:20 pm
by DannyC
I want to add another date column to the Contacts notes grid.
Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaForm is JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)
   {
      JiwaFinancials.Jiwa.JiwaContactsUI.frmContact contactForm = (JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)JiwaForm;
      contactForm.grdNotes.AddColumn("InteractDate",FarPoint.Win.Spread.CellType.DateTimeCellType, "Date Interaction",10,false,true,true,false,20,false,false,0,false,false);
   }
}


Getting a compile error "FarPoint.Win.Spread.CellType.DateTimeCellType is a 'type' which is not valid in the given context".

What's the correct celltype?

Re: Add extra date column to Notes grid  Topic is solved

PostPosted: Thu Oct 06, 2022 5:22 pm
by DannyC
Never mind, got it sorted.
For those interested the code should be
Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaForm is JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)
   {
      JiwaFinancials.Jiwa.JiwaContactsUI.frmContact contactForm = (JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)JiwaForm;
      contactForm.grdNotes.AddColumn("InteractDate",new FarPoint.Win.Spread.CellType.DateTimeCellType(), "Date Interaction",10,false,true,true,false,20,false,false,0,false,false);
   }
}

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 8:38 am
by DannyC
Another issue with this plugin.....I have a combobox.
But when I have selected my combo value then click elsewhere - setting the focus somewhere else, the value disappears from the column.

This is my code. I know I must be missing a line somewhere which keeps the combo value in the column but not sure what that line is.

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaForm is JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)
   {
      JiwaFinancials.Jiwa.JiwaContactsUI.frmContact contactForm = (JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)JiwaForm;
      jiwaGrid = contactForm.grdNotes;
      contactForm.grdNotes.AddColumn("InteractDate",new FarPoint.Win.Spread.CellType.DateTimeCellType(), "Date Interaction",10,false,true,true,false,20,false,false,0,false,false);
         
      FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxCellType = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
        string[] interactionReasons = new string[] { "Reason 1", "Reason 2", "And another reason" };
        comboBoxCellType.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.String;
        comboBoxCellType.Items = interactionReasons;
        contactForm.grdNotes.AddColumn ("Reason", comboBoxCellType, "Reason",10,false,true,false,false,20,false,false,0,false,false);
      contactForm.grdNotes.AddColumn ("MyNotes", new FarPoint.Win.Spread.CellType.TextCellType(), "More text",10,false,true,false,false,20,false,false,0,false,false);
      contactForm.grdNotes.AddColumn("FupDate",new FarPoint.Win.Spread.CellType.DateTimeCellType(), "Date FollowUp",10,false,true,true,false,20,false,false,0,false,false);
      contactForm.grdNotes.SetupComplete();
         
      contactForm.Contact.SaveEnding += Attkey_ContactsSave;
         
         
   }
}

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 9:15 am
by SBarnes
I suspect it's because you are only setting items, you also need to set the item data and the editor value, here is how the Note Type is done on the same grid

Code: Select all
 Dim noteTypeDescriptions As New List(Of String)
            Dim noteTypeIDs As New List(Of String)
            For Each noteType As JiwaApplication.Notes.NoteType In _businessLogicNoteCollection.NoteTypeCollection
                noteTypeDescriptions.Add(noteType.Description)
                noteTypeIDs.Add(noteType.RecID)
            Next
            Dim noteTypeComboBoxCellType As CellType.ComboBoxCellType = New CellType.ComboBoxCellType
            noteTypeComboBoxCellType.Items = noteTypeDescriptions.ToArray
            noteTypeComboBoxCellType.ItemData = noteTypeIDs.ToArray
            noteTypeComboBoxCellType.EditorValue = CellType.EditorValue.ItemData
            noteTypeComboBoxCellType.Editable = False
            grdNotes.AddColumn("Type", noteTypeComboBoxCellType, "Type", 20, False, True, True, False, 255, False, False, 0, False, False)

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 11:03 am
by DannyC
Already had the editor value but have tweaked my code & now I get the selected combo value staying there if I move focus away.

But I can't get the value. Note how I am setting an object jiwaGrid. Then using it to grab the values.

Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid jiwaGrid;

   public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaForm is JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)
   {
      JiwaFinancials.Jiwa.JiwaContactsUI.frmContact contactForm = (JiwaFinancials.Jiwa.JiwaContactsUI.frmContact)JiwaForm;
      jiwaGrid = contactForm.grdNotes;
      contactForm.grdNotes.AddColumn("InteractDate",new FarPoint.Win.Spread.CellType.DateTimeCellType(), "Date Interaction",10,false,true,true,false,20,false,false,0,false,false);
         
      FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxCellType = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
        string[] interactionReasons = new string[] { "Reason 1", "Reason 2", "And another reason" };
        comboBoxCellType.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.String;
      comboBoxCellType.ItemData = interactionReasons.ToArray();
        comboBoxCellType.Items = interactionReasons.ToArray();
        contactForm.grdNotes.AddColumn ("Reason", comboBoxCellType, "Reason",10,false,true,false,false,20,false,false,0,false,false);
      contactForm.grdNotes.AddColumn ("MyNotes", new FarPoint.Win.Spread.CellType.TextCellType(), "More text",10,false,true,false,false,20,false,false,0,false,false);
      contactForm.grdNotes.AddColumn("FupDate",new FarPoint.Win.Spread.CellType.DateTimeCellType(), "Date FollowUp",10,false,true,true,false,20,false,false,0,false,false);
      contactForm.grdNotes.SetupComplete();
         
      contactForm.Contact.SaveEnding += Attkey_ContactsSave;
         
         
   }
.
.
.
MessageBox.Show(myNote.RecID + "     " + contact.RecID + "     " + jiwaGrid.get_GridText("InteractDate", myNote.ItemNo) + "     " + jiwaGrid.get_GridText("Reason", myNote.ItemNo).ToString());

}


this code is generating "object reference not set to an instance of an object":
Code: Select all
jiwaGrid.get_GridText("Reason", myNote.ItemNo).ToString()

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 11:13 am
by SBarnes
I think it should be


Code: Select all
jiwaGrid.get_GridText("Reason", myNote.RecID).ToString()


not ItemNo

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 11:41 am
by DannyC
Nah, it needs to be an INT

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 11:47 am
by Mike.Sheen
DannyC wrote:Nah, it needs to be an INT


It doesn't NEED to be - we let you invoke GridText with either the Row number or the Key / RecID - GridText is overloaded to accept either.

You will need to inspect at / before the point of the exception to see why you are getting the null reference ("object reference not set to an instance of an object") error.

Re: Add extra date column to Notes grid

PostPosted: Tue Oct 11, 2022 11:47 am
by SBarnes
Oh ItemNo starts at one grid index starts at zero try -1 from itemno