report from a TList<T>

Hi,


first I want to say thank you for this great release. It is really helpful to me.

second, I have a lot of data structures that are represented by Lists of interfaces instead of Lists of objects. I can syntactically use AddTable<T> with an interface type (it compiles) but on report.Run I get runtime errors which tell me that the properties I am using in my template file don't exist. (while they really do exist)
If I create a new List of objects and add my interface based objects with a cast to that new list ( newlist.add(TMyObject(myInterfaceBasedObject)) ), I can pass them to the report and run it without runtime errors. 
Question: Would it be a simple thing for you to add support also for Lists or Arrays that contain interfaces?
If it's not a simple thing, forget it, otherwise it would be of great help because I could avoid copying my data to report specific data structures and directly use my interface based data structures (maybe this applies also to other users ?)

thanks

Martin

Let me check, I'll let you know if possible.


We currently use RTTI to get the fields names, and maybe it needs some adjustment to work with interfaces, or maybe we can use QueryInterface instead.

If there is a not too complex way to add List<interface>, we will.

Hi,

I've been investigating, and you can make a report from TList<Interface>, if the interface is compiled with {$M+}, like:

{$M+}
  MyInterface = interface
   ...
end;
{$M-}

(you might not writ the $M-, and just wrap the whole unit in $M+)
Now, about the limitations:
  Since there is not RTTI for properties in interfaces, you can only call methods of the interface. You can't of course call fields because the interface doesn't have them (even if the object implementing the interface has them).

If you can live with this limitation. It should work. I think a basic report should run in 6.6.1 as long as you use $M+, but I've improved the support in 6.6.2 to fully support interfaces everywhere. We should be publishing 6.6.2 this friday if no problems appear.

sounds great


my interfaces declare properties which use getter methods of the same interface

will investigate how far I can get with $M+

Then you need to reference the methods, not the properties in the template. That is, if you have:

{$M+}
myintf = interface
  function GetName: string;
  property Name: string read GetName;
end;

in the template you should write:
  <#myintf.GetName>

sadly <#myintf.Name> won't work, because delphi doesn't have RTTI for properties in interfaces.

Would it be possible as a convenience functionality to try find a method in the interface with a prefixed 'Get' in the case where a used name doesn't exist in the dataset?

That would solve the issue if one uses the convention to name the getter methods with a prefixed 'Get'
What do you think?

I think this should be possible, yes, but I am thinking if it wouldn't bring some side effects. I'll see if it can be implemented.

Hi,

6.6.2 (just released in our website) should have better support for interfaces (as said, you need to use $M+, and also no properties, because Delphi doesn't have RTTI for properties in interfaces)

I've added also your suggestion of ignoring the "Get" in methods when using interfaces, so while a property Name won't be recognized, if you have a method GetName you will be able to write <#data.Name> and FlexCel will know it has to call GetName.

Hope this helps
   Adrian.