Disabling editors at runtime

Hey folks,


On our TTMSFMXLIveGrid, we want to disable any editing whatsoever on a Cell mapped via LiveBindings to a TBlobField (the TBlobField(s) contain photos associated with a line's product code).  As far as the desired UX goes, when a user clicks/taps the cell, a TMultiView drawer is opened to select/manage the photo and then we assign the photo to the TBlobField manually via code.

We've tried the following:

1) Setting (Cell as TTMSFMXBitmapGridCell).Bitmap.HitTest := False in Grid.OnGetCellProperties
2) Setting Column.ReadOnly in the Grid.Columns[x] property
3) Setting TTMSFMXEdit(CellEditor).Enabled := False in OnGetCellEditorProperties for the respective photo columns [ i.e. if (ACol = 5) then Editor.Enabled := False; otherwise Editor.Enabled := True ]

The combination of all 3 gives us the UX we're looking for; however, internally it causes issues.  After tapping on a photo field, then tapping on another field, the grid internally throws an "Invalid class typecast" during TMS.Tmslivegrid.TTMSFMXLiveGrid.NotifyObserverStopEdit().

We tried setting TTMSFMXEdit(CellEditor).CanEditObserve := False, but it had no effect.

Steps to reproduce:

1) Create a new FMX project and add a TTMSFMXLiveGrid bound via LiveBindings to a FDMemTable (FireDAC memtable) containing one or more TBlobFields loaded w/ images
2) Imeplement (Cell as TTMSFMXBitmapGridCell).Bitmap.HitTest := False in Grid.OnGetCellProperties
3) Setting Column.ReadOnly in the Grid.Columns[x] property for the appropriate image columns
4) Implement TTMSFMXEdit(CellEditor).Enabled := False in OnGetCellEditorProperties for the respective photo columns [ i.e. if (ACol = 5) then Editor.Enabled := False; otherwise Editor.Enabled := True ]

Note: if you run without any breakpoints, the IDE never pauses to display the exception

In order to actually see/catch the exception in the IDE, set a breakpoint on any line within the application (e.g. during the CellEditor.Enabled := False statement).  Resume execution when the breakpoint is hit, then tap/click on any other cell.  The IDE will eventually pause showing the "Invalid class typecast" exception, and you can pause/break to see where internally the exception is occurring.

Perhaps there is another approach we should be taking to disable the editors from showing/enabling for photo fields (or any field we want to prevent editing on, in the long run)

We have a demo project ready to send to you if you prefer.   Please advise! 

Update - We are currently using TMS Pack for Firemonkey v3.3.0.0

Hi, 


We are not able to reproduce this here with the steps you are referring to, can you perhaps send us a sample that is able to reproduce this issue with a TClientDataSet or another default available dataset?

Additional testing/observations:


1) exception does not occur on Win32 and/or iOS Simulator builds, but is seen on iOS 32/64bit builds after a breakpoint has been triggered
2) When no breakpoint set, the exception/observer notify interferes with other events occurring in/at the same as the exception (e.g. in our main app, the TMultiView drawer is in the middle of showing, but then immediately hides as the grid is re-focused?)

Note: We are currently using iOS9.3 (latest) in our testing.

Hey Pieter,


Where can I send the sample project to?

See:http://www.tmssoftware.com/site/support_mail.asp

Thank you for the additional information, we were testing this here on Windows. You can send the project to support@tmssoftware.com with a reference to this forum post. I will take a look at it as soon as possible.

Much appreciated, Pieter - I've sent it via email (direct) to support@tmssoftware.com.  I've also modified the project to use TClientDataSet as requested.


Setting a breakpoint @ line 107 of mainform.pas will allow you to see the exception/stack trace as described above.

Thank you for your project ,will take a look at it as soon as possible.

Hi, 


I have been able to reproduce this issue, yet I wonder in which RAD Studio version you are currently working? We have tested this here in 10 Seattle and have re-added the TTMSFMXLiveGrid and added a new LiveBindings connection and we no longer get the invalid typecast issue.

Hey Pieter,


We are using Delphi 10 Seattle (Update 1).  I will try re-adding the grid and LiveBindings connection to see if that works for our app as well.

HI Pieter,


Re-adding the components did work for our app as well.  Thank you for investigating.  We'll keep this solution in mind moving forward (may be required in our other apps as well).

Hey Pieter,

May have found a way to reproduce this reliably.  It seems when we set grid.Options.DirectEdit := True, we receive the "Invalid Class Typecast" error.  However, when we turn off DirectEdit, no more errors.

This seems consistent with "re-adding the grid" without setting DirectEdit back to True.  Did you want to try this on your end as well to confirm?

Thank you!

It seems to be a binding issue, regardless of the DirectEdit state. We have tried but haven't been able to reproduce this issue. It could be possible that the project is an upgrade of an older project, or some bindings have been changed (we have recently updated the LiveBindings support) that unfortunately needs bindings to be reinitialized when added at designtime.