Custom column in debtor contacts  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Custom column in debtor contacts

Postby DannyC » Wed Oct 26, 2022 2:22 pm

I've just knocked up a fairly simple plugin which adds a datetime column to the grd.ContactNames grid. See plugin attached.

When I edit the field my issue is that I don't know how to make the debtors screen dirty so that save is enabled.
And also how do I make that particular row dirty - i.e how do I set the ChangeFlag property to true?
Attachments
Plugin Attkey Add columns to Contacts.xml
(42.49 KiB) Downloaded 51 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Custom column in debtor contacts  Topic is solved

Postby Mike.Sheen » Wed Oct 26, 2022 6:31 pm

Listen to the grid changed event - if your new column changes, invoke the NotifyPropertyChanged method of the corresponding contact name in the business logic. That'll set the change flag on the contact name, the collection and bubble events up to the UI so it knows something has changed.

Attached does this - I also added an index to your custom table in the SQL script attached to the documents, because without it performance is likely to suffer with a lot of contacts.

I also got rid of your global grid declaration you were using - that would have issues with multiple debtor maintenance forms open at once, as each time a debtor maintenance form opens the grid variable you had would have been overwritten with the current forms contact names grid. Hilarity would have ensued.

You still have an issue in your save logic, but you probably don't need me to work out what that is, or need me to fix it.
Attachments
Plugin Attkey Add columns to Contacts V2.xml
(20.74 KiB) Downloaded 46 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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Custom column in debtor contacts

Postby SBarnes » Wed Oct 26, 2022 6:43 pm

When I edit the field my issue is that I don't know how to make the debtors screen dirty so that save is enabled.


You should be able to set the change flag on the debtor to true and then usually there is a function called CheckEditStatus on most forms including debtors, if its not publicly available there is an old expression fake it to you make it, just set the debtor name equal to the debtor name and that will make things detect the change.

And also how do I make that particular row dirty - i.e how do I set the ChangeFlag property to true?


You need to attach a change event to grdContactNames for example below is the one from Jiwa for the contact grid itself, yours should follow behind just looking for your column

Code: Select all
 Private Sub grdContactNames_Change(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.ChangeEventArgs)
        Dim TempString As String = ""
        Dim Title As String = ""
        Dim FirstName As String = ""
        Dim Surname As String = ""
        Dim Phone As String = ""
        Dim Mobile As String = ""
        Dim Fax As String = ""
        Dim Email As String = ""
        Dim LogonCode As String = ""
        Dim LogonPassword As String = ""

        If Debtor.IsReading = False Then
            With grdContactNames
                If e.Row >= 0 Then
                    TempString = .GridText(.ActiveSheet.Columns(e.Column).Tag, e.Row)
                    Dim Key As String = .GridText("Key", e.Row)
                    If Key.Length = 0 Then
                        Dim contactName As JiwaDebtors.ContactName = Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaDebtors.ContactName)()
                        Select Case .ActiveSheet.Columns(e.Column).Tag
                            Case "Title"
                                contactName.Title = TempString
                            Case "FirstName"
                                contactName.FirstName = TempString
                            Case "Surname"
                                contactName.Surname = TempString
                            Case "Phone"
                                contactName.Phone = TempString
                            Case "Mobile"
                                contactName.Mobile = TempString
                            Case "Fax"
                                contactName.Fax = TempString
                            Case "Email"
                                contactName.EmailAddress = TempString
                            Case "LogonCode"
                                contactName.LogonCode = TempString
                            Case "LogonPassword"
                                contactName.LogonPassword = TempString
                        End Select
                        _Debtor.ContactNames.Add(contactName)
                    Else
                        Key = .GridText("Key", e.Row)
                        If Key.Trim.Length > 0 Then
                            Select Case .ActiveSheet.Columns(e.Column).Tag
                                Case "Title"
                                    _Debtor.ContactNames(Key).Title = TempString
                                Case "FirstName"
                                    _Debtor.ContactNames(Key).FirstName = TempString
                                Case "Surname"
                                    _Debtor.ContactNames(Key).Surname = TempString
                                Case "Phone"
                                    _Debtor.ContactNames(Key).Phone = TempString
                                Case "Mobile"
                                    _Debtor.ContactNames(Key).Mobile = TempString
                                Case "Fax"
                                    _Debtor.ContactNames(Key).Fax = TempString
                                Case "Email"
                                    _Debtor.ContactNames(Key).EmailAddress = TempString
                                Case "LogonCode"
                                    _Debtor.ContactNames(Key).LogonCode = TempString
                                Case "LogonPassword"
                                    _Debtor.ContactNames(Key).LogonPassword = TempString
                            End Select
                        End If
                    End If
                End If
            End With
        End If
    End Sub
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Custom column in debtor contacts

Postby SBarnes » Wed Oct 26, 2022 6:53 pm

Hmm, answers in stereo now :lol:

If you really wanted to to have a go at doing it the purist right way you could turn your table into a Jiwa collection item and then create a Jiwa collection class as well and keep that in the debtors generic object collection and pull it from there on the saves and reads and changes etc.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Custom column in debtor contacts

Postby DannyC » Thu Oct 27, 2022 10:19 am

Appreciate the replies.

After I posed the question I was thinking about it a few hours later & realised I should just hook into the Changed event. Duh. Then I read Mike's plugin :D
Some nice information in there.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 29 guests