Grid custom checkbox column  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Grid custom checkbox column

Postby neil.interactit » Wed Oct 28, 2015 11:40 am

I am adding some custom columns programmatically ... all working well. The following code:

Code: Select all
    Private Sub ShowLedgerNumberColumn(activeSheet As Sheet)
        Dim xmlString = activeSheet.GenerateXMLDefinition()
        Dim xmlDocument = New XmlDocument
        xmlDocument.LoadXml(xmlString)
        Dim listOfColumns As XmlElement = xmlDocument.SelectSingleNode("JiwaGridDefinition/ListOfColumns")
        If listOfColumns Is Nothing Then Return
        Dim updated = ShowColumnAs(listOfColumns, "UserDefinedString1", "Ledger Number")
        updated = updated Or ShowColumnAs(listOfColumns, "UserDefinedString2", "Receipt")
        updated = updated Or ShowColumnAs(listOfColumns, "UserDefinedString3", "Creditor Purchase")
        If updated Then activeSheet.ApplyXMLDefinition(xmlDocument.OuterXml)
    End Sub

    Private Function ShowColumnAs(listOfColumns As XmlElement, key As String, caption As String) As Boolean
        For Each column As XmlElement In From col As XmlElement In listOfColumns.ChildNodes Where col.SelectSingleNode("Key").FirstChild().Value = key
            If column.SelectSingleNode("Caption").FirstChild().Value = caption And column.SelectSingleNode("Hidden").FirstChild().Value = "0" Then Return False
            column.SelectSingleNode("Caption").FirstChild().Value = caption
            column.SelectSingleNode("Hidden").FirstChild().Value = "0"
            Return True
        Next
        Return False
    End Function

Produces:
grid1.PNG
grid1.PNG (4.58 KiB) Viewed 5160 times


This approach uses UserDefinedString1/UserDefinedString2/UserDefinedString3. There is no UserDefinedCheckbox1 ... is there a way I can jump in with grid event handlers of something to overide the grid display and show a checkbox, and then set UserDefinedString2 (in this case) to "True" or "False" ...
grid.png
grid.png (3.8 KiB) Viewed 5160 times
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Grid custom checkbox column

Postby Mike.Sheen » Sun Dec 06, 2015 11:14 am

In theory if you hook into the readend event from the UI (as in, in the UI add a handler to the business logic readend), you could then set the cell type for each row of the desired columns.

Which form are you attempting to do this in? Let us know and I'll have a crack at it.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Grid custom checkbox column

Postby neil.interactit » Tue Dec 08, 2015 11:38 am

Hi Mike,

This is on JiwaPurchaseOrdersUI.PurchaseOrders. As an interim measure, I have fudged with toggled text "Yes" and "No" on _purchaseOrderForm.LinesJiwaGrid.CellClick, which gives the functionality in a clunky fashion.

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Grid custom checkbox column

Postby Mike.Sheen » Sat Feb 27, 2016 5:52 pm

Bumping as was never marked as solved.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Grid custom checkbox column

Postby neil.interactit » Wed Mar 02, 2016 9:44 am

Hi Mike,

I deployed the fudge fix, to keep the client happy. I was keeping an eye out for your crack at it, and then intending to update the plugin.

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Grid custom checkbox column  Topic is solved

Postby Mike.Sheen » Sat Mar 12, 2016 11:21 am

Attached is a plugin which makes the UserDefinedFloat1 column on purchase orders a checkbox.

POLines_Checkbox.PNG
Column now a Checkbox
POLines_Checkbox.PNG (5.09 KiB) Viewed 5111 times


I just hooked into the ReadEnd of the PO, then set the celltype of the column and then copied that to each cell in the grid:

Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      var purchaseOrderForm = (JiwaFinancials.Jiwa.JiwaPurchaseOrdersUI.MainForm)JiwaForm;
      purchaseOrderForm.PurchaseOrder.ReadEnd += PurchaseOrder_ReadEnd;
    }
   
   private void PurchaseOrder_ReadEnd(object sender, System.EventArgs e)
   {
      var purchaseOrder = (JiwaFinancials.Jiwa.JiwaPurchaseOrders.PurchaseOrder)sender;
      var purchaseOrderForm = (JiwaFinancials.Jiwa.JiwaPurchaseOrdersUI.MainForm)purchaseOrder.Client;
      
      // change the celltype of the UserDefinedFloat1 column to be a checkbox
      purchaseOrderForm.LinesJiwaGrid.ActiveSheet.Columns["UserDefinedFloat1"].CellType = new FarPoint.Win.Spread.CellType.CheckBoxCellType();
      purchaseOrderForm.LinesJiwaGrid.ActiveSheet.Columns["UserDefinedFloat1"].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
      // copy the celltype and alignment from the column to each cell
      for(int row = 0; row < purchaseOrderForm.LinesJiwaGrid.ActiveSheet.RowCount; row++)
      {
         purchaseOrderForm.LinesJiwaGrid.ActiveSheet.Cells[row, purchaseOrderForm.LinesJiwaGrid.ActiveSheet.GetColumnFromTag(null, "UserDefinedFloat1").Index].CellType = purchaseOrderForm.LinesJiwaGrid.ActiveSheet.Columns["UserDefinedFloat1"].CellType;
         purchaseOrderForm.LinesJiwaGrid.ActiveSheet.Cells[row, purchaseOrderForm.LinesJiwaGrid.ActiveSheet.GetColumnFromTag(null, "UserDefinedFloat1").Index].HorizontalAlignment = purchaseOrderForm.LinesJiwaGrid.ActiveSheet.Columns["UserDefinedFloat1"].HorizontalAlignment;
      }
   }
Attachments
Plugin Purchase Orders - make column checkbox.xml
Plugin - make column checkbox on PO
(31.46 KiB) Downloaded 931 times
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Grid custom checkbox column

Postby neil.interactit » Fri May 27, 2016 11:35 am

I had forgotten to tick this one. Awesome Mike, many thanks.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests