Add extra date column to Notes grid  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Add extra date column to Notes grid

Postby DannyC » Thu Oct 06, 2022 4:20 pm

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?
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

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

Postby DannyC » Thu Oct 06, 2022 5:22 pm

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);
   }
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add extra date column to Notes grid

Postby DannyC » Tue Oct 11, 2022 8:38 am

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;
         
         
   }
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add extra date column to Notes grid

Postby SBarnes » Tue Oct 11, 2022 9:15 am

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)
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add extra date column to Notes grid

Postby DannyC » Tue Oct 11, 2022 11:03 am

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()
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add extra date column to Notes grid

Postby SBarnes » Tue Oct 11, 2022 11:13 am

I think it should be


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


not ItemNo
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add extra date column to Notes grid

Postby DannyC » Tue Oct 11, 2022 11:41 am

Nah, it needs to be an INT
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add extra date column to Notes grid

Postby Mike.Sheen » Tue Oct 11, 2022 11:47 am

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Add extra date column to Notes grid

Postby SBarnes » Tue Oct 11, 2022 11:47 am

Oh ItemNo starts at one grid index starts at zero try -1 from itemno
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 31 guests