Login / Register  search  syndication  about

          Kris Halsrud's Blog

Kris Halsrud on development and Integration with CRM and Development

Formatting a datagrid's cells to have custom colors in the SalesLogix LAN client

A client recently posed a question to me regarding if you can customize the SalesLogix grid in the LAN client to have coloring applied based upon conditions.  The answer is yes you can.  lets take a look at how.

The SalesLogix data grid control has an event called OnCustomDrawCell.  This event has several arguments that are passed in including:

  • Sender- the grid control
  • Node- The row in the grid
  • Column- The column being rendered
  • IsSelected- A boolean expressing if the cell is selected
  • IsFocused- A boolean expressing if the cell is currently in focus
  • Text- Writable property relating to the text displayed in the grid
  • Color- Writable property relating to the background color of the cell displayed in the grid
  • Alignment- Writable property relating to the text alignment in the grid 
  • Font- Writable property relating to the text's font displayed in the grid
  • FontColor- Writable property relating to the text's color displayed in the grid

Lets take a look at how we might examine the contents of a given row, and then based on that information do something to another cell:

Sub grdContactsCustomDrawCell(Sender, ByRef Node, ByRef Column, IsSelected, IsFocused, ByRef Text, ByRef Color, ByRef Alignment, ByRef Font, ByRef FontColor)
Dim sFieldName
Dim vName
Dim lColumnIndex
Dim vID

    sFieldName = UCase(Column.FieldName) ' Field you want to look for

    Select Case sFieldName
        Case "ISPRIMARY" ' ALIAS name of the column in QB
            lColumnIndex = GetColumnIndexByFieldName ( grdContacts,"NAMELF" ) ' Used so that grid can be sorted/grouped
            vName = Node.Values ( lColumnIndex ) ' Gets the actual value           

        If Not IsNull ( vName ) Then ' Ensure you check for Nulls   

            Select Case ucase(left(vName,1))
                Case "A"
                Color = rgb(255,0,0)
                Font.Bold = True
                FontColor = rgb(0,255,0)
            End Select
        End If
    End Select
End Sub

Function GetColumnIndexByFieldName ( ByRef Grid, ByVal FieldName )
Dim i
Dim lColumnIndex

    lColumnIndex = -1
    For i = 0 To Grid.Columns.Count - 1
        If UCase ( Grid.Columns(i).FieldName ) = UCase ( FieldName ) Then
            lColumnIndex = i
            Exit For
        End If
    Next
    GetColumnIndexByFieldName = lColumnIndex
End Function

In the code above we have a case statement that is looking to see if the column of the cell being rendered is the "ISPRIMARY" column. 

    Select Case sFieldName
        Case "ISPRIMARY" ' ALIAS name of the column in QB
            lColumnIndex = GetColumnIndexByFieldName ( grdContacts,"NAMELF" ) ' Used so that grid can be sorted/grouped
            vName = Node.Values ( lColumnIndex ) ' Gets the actual value           
   

If it is it then uses the function GetColumnIndexByFieldName which retruns the column index of a different column we want to find.  In this example we re finding the index position of the "NAMELF" column.  With that index position identified we can then use the Node.Values() function to fetch the value in the column index position specified.

With the Name value having been captured, we can then do something with with it.  In our example we are looking to see if it starts with "A".  if it does then we are setting things like the Color, Font.Bold, and FontColor.

The end result is a grid with color coding:

 

One last thing.  Suppose you want to get data related to the record but not necessarily in the grid.  Well if you want to get the ID of the record that is being rendered you can use something like this:

 vID = sender.GetCurrentField(sender.KeyField) 'Gets the primary keyfield of the current row.

 Note: this code does run per cell that is rendered so it can increase the time to render the grid, especially if you are loading a grid with lots of records.

 

What's This?
  
Bookmark and Share

About Kris Halsrud

   Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.


Related Content
   Infor CRM (formerly Saleslogix) Web- Dependency Lookup OnChange Event Not Working Correctly
In the Saleslogix 8.1 web client the dependency lookup still has a problem with the OnChange event. 
Posted on Nov 26, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Confirming Actions With an "Are you sure?" Prompt in Infor CRM (Saleslogix)
I'm not a huge fan of bugging end users. I figure, if an end user clicked something, he or she meant
Posted on Nov 18, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Infor CRM (formerly Saleslogix) Statement of Direction
Learn more about the future of Infor CRM. Recently I received my login information for the Infor Partn
Posted on Nov 13, 2014 by Brianna Ojard to The Inbox
 
   Xbar for InforCRM (formerly SalesLogix) Installation Issue
After installing Xbar 1.1 on a Windows 2008 R2 server the Xbar application was not available in Outlook 2
Posted on Nov 11, 2014 by Mark Duthoy to SalesLogix Support
 
   Programmatically Using Security Roles and Secured Actions in Infor CRM (Saleslogix)
In most places in the Infor CRM (Saleslogix) web client, it's pretty easy to use security roles. You
Posted on Nov 07, 2014 by Ryan Farley to Ryan Farley's Blog
 
Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2014 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register