简体   繁体   English

delphi 2010 datasnap从服务器返回树视图

[英]delphi 2010 datasnap return treeview from server

is it possible in Delphi Datasnap 2010 to transfer treeview from Datasnap 2010 server to DataSnap Client? Delphi Datasnap 2010中是否可以将Trees从Datasnap 2010服务器传输到DataSnap Client?

thanks 谢谢

You might be able to kludge something together that creates and populates a VCL control on the server and serialize the control to the client, but it seems ugly. 您可能可以将某些东西融合在一起,从而在服务器上创建并填充VCL控件,并将该控件序列化到客户端,但这看起来很丑。

I would have it return the data that represents a tree and use that to populate a treeview on the client side, instead. 我会让它返回代表一棵树的数据,并使用它来填充客户端的树视图。

NodeId  NodeName  ParentId
0       Root      -1
1       Node1     0
2       Node2     0
3       Node3     0
4       Node1.1   1

Instead of transferring GUI elements from servers to clients, it is a common practice to transfer the data only (for example as 'data transfer objects', DTO) which can easily be (de-)serialized using open source libraries like OmniXML , NativeXML or SuperObject . 除了将GUI元素从服务器传输到客户端外,通常的做法是仅传输数据(例如,作为“数据传输对象”(DTO)),可以使用OmniXMLNativeXML超级对象

The presentation layer can change easily (think of HTML or mobile clients) this way. 表示层可以通过这种方式轻松更改(例如HTML或移动客户端)。

The definition for DTO can be found on Martin Fowler's site. DTO的定义可以在Martin Fowler的网站上找到。

DataSnap can serialize objects using JSON. DataSnap可以使用JSON序列化对象。 I recommend you create a tree structure in which you would store the nodes and then populate your treeview accordingly. 我建议您创建一个树结构,在其中存储节点,然后相应地填充树视图。

And no, you cannot serialize a VCL TTreeView. 不,您不能序列化VCL TTreeView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM