8/18/2025 7:27:47 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
|
|
|
|
.DisableEditor=True in Datagrid error
Posted: 28 Dec 07 10:00 AM
|
I am trying to use the following code to disable an editable date field in a datagrid (v7sp1).. I have used this code successfully in the past and am not sure why it is not working this time.
I am firing the following code from the CustomDrawCell event - the field name and display name are 'Online_Date' and grid is named dgProduction: dgProduction.Columns.Item("Online_Date").DisableEditor=True
I get the error: Object Required: 'dgProduction.Columns.Item(...)'
The code looks identical to the working code I copied from... I have triple checked the spelling of all fields and controls.. any thoughts on why this might be happening? Thanks |
|
|
|
Re: .DisableEditor=True in Datagrid error
Posted: 02 Jan 08 12:48 PM
|
Could you display the code for the whole method? I have a few ideas - if you don't have a conditional IF statement in there, and the line of code is being run every time the CustomDrawCell event is being fired, then when the event is fired for a new line on the datagrid, the cell won't exist yet, which would give you the error.
One other thing that stands out to me - I'm sure using the field name works, but I always use the index instead, so I don't know if dgProduction.Columns.Item(...) is looking for the field name or the caption of the field. This one is a stretch, but it's the only other thing I can think of without having all of the code from the method. |
|
|
|
Re: .DisableEditor=True in Datagrid error
Posted: 02 Jan 08 1:57 PM
|
You can avoid the name/caption (and also the sort issue - when you click a sort column you'll get errors too) by following this code:
================ Colouring a grid ================
For the Grid - select the property "OnCustomDrawCell" - this will create a sub based on the name of the grid followed by CustomDrawCell e.g. --------------|-------------| Sub dgServicesCustomDrawCell(Sender, ByRef Node, ByRef Column, IsSelected, IsFocused, ByRef Text, ByRef Color, ByRef Alignment, ByRef Font, ByRef FontColor)
Dim sFieldName Dim vStatus Dim lColumnIndex
sFieldName = UCase ( Column.FieldName ) ' Field you want to look for
Select Case sFieldName Case "A2_STATUS" ' ALIAS name of the column in QB lColumnIndex = GetColumnIndexByFieldName ( dgServices,"A2_STATUS" ) ' Used so that grid can be sorted/grouped vStatus = Node.Values ( lColumnIndex ) ' Gets the actual value End Select
If Not IsNull ( vStatus ) Then ' Ensure you check for Nulls
Select Case vStatus Case "Open" FontColor = &H00000000 ' in v7.x - you can use enum of clBlack, clGreen etc Case "Lost" FontColor = &H000000FF Case "Won" FontColor = &H00800000 Font.Bold = True End Select End If
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
Just put in your options during the Case item.
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|