Renaming the "Duty"'field on a GRN  Topic is solved

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

Renaming the "Duty"'field on a GRN

Postby Atronics » Wed Feb 17, 2016 5:47 pm

I need to rename the Duty field on the GRN form. Using the Permissions option to find the fieldname does not identify this field.
Atronics
Frequent Contributor
Frequent Contributor
 
Posts: 119
Joined: Fri Feb 29, 2008 4:40 pm
Topics Solved: 10

Re: Renaming the "Duty"'field on a GRN  Topic is solved

Postby Scott.Pearce » Thu Feb 18, 2016 8:07 am

It's a cell in a grid. Using the "Set Permissions" form, I can see that grid is called "CartageJiwaGrid". Using "Manage Grid", I can see that the column tag for the column in which the text "Duty" resides is "RowHeading". Using "Manage Grid", I also reveal the "Key" column, and find that the row for "Duty" has a key of "Duty". The key column allows identification of a given row even when the grid is sorted in some arbitrary way. In many of our grids the "key" of a row would be the RecID related to the record data being displayed.

To change the text of the Duty cell, one would start by hooking into an appropriate event - I chose form_shown because by this point all the controls have been set up:

Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim GRNFormObject As JiwaInvReceivalUI.MainForm = JiwaForm
      AddHandler GRNFormObject.Shown, AddressOf GRNFormObject_Shown
    End Sub


Don't forget to add a reference to the "Goods Received Note" form on the Forms tab of the plugin!

Then, the handler itself is thus:

Code: Select all
   Public Sub GRNFormObject_Shown(sender As Object, e As System.EventArgs)
      Dim GRNFormObject As JiwaInvReceivalUI.MainForm = sender
      
      With GRNFormObject.CartageJiwaGrid
         Dim rowKey As String = ""
         Dim dutyRowNo As Integer = -1
         
         'Find the Duty row
         For MyLoop As Integer = 0 To .ActiveSheet.RowCount - 1 'Grids are 0-based - the - 1 accounts for this.
            rowKey = .GridText("Key", MyLoop)
            If rowKey = "Duty" Then
               dutyRowNo = MyLoop
               Exit For 'We've found the row we are interested in.
            End If
         Next
         
         'Assuming we found the Duty row OK, we can now set the text of the "RowHeading" column for that row.
         .GridText("RowHeading", dutyRowNo) = "Import Levy"
      End With
   End Sub


In the handler code, we start by obtaining the form via the "sender" of the event - this allows us to reach the grid of interest. Then, we iterate through the grid looking for the "Duty" row. Finally, having found the row we want to modify, we use GridText to set the text of the cell at column "RowHeading", row "dutyRowNo".

I've attached the full plugin.
Attachments
Plugin GRN Duty Rename.xml
(31.55 KiB) Downloaded 392 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Renaming the "Duty"'field on a GRN

Postby Atronics » Thu Feb 18, 2016 10:29 am

Thanks, Scott.
Atronics
Frequent Contributor
Frequent Contributor
 
Posts: 119
Joined: Fri Feb 29, 2008 4:40 pm
Topics Solved: 10


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests