Jump to content


Photo

TUniTreewView

TUniTreewView

  • Please log in to reply
12 replies to this topic

#1 Marlon

Marlon

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 378 posts
  • LocationNova Mutum - MT - Brasil

Posted 12 February 2015 - 08:18 PM

add new input field.

 

UniTreeView.png


  • 0

Best Regards
Marlon Nardi
www.falconsistemas.com.br

 

(Store) https://store.falconsistemas.com.br - HyperServer

(Finance) https://app.falconsistemas.com.br - HyperServer

(Json to Delphi Class) https://jsontodelphi.com


#2 Abaksoft

Abaksoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 637 posts
  • LocationAlgeria

Posted 12 February 2015 - 09:52 PM

Why Marlon ?
What is the purpose ?

If you want to store a textField for each node, look at the new demo 0.99. Farshad used a very nice technic for that :
Just create a TStringList and store on it this syntaxe :

L:=TStringList.Create
L.add('myNode1=myText1')
L.add('myNode2=myText2')
...
Then L.Values['myNode2'] gives you myText2

Could this be your Field additional ?
For more details see AllFeaturesDemo project on the mainForm.onCreate
(FileName : TStrings)

Regards.
  • 0

#3 Marlon

Marlon

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 378 posts
  • LocationNova Mutum - MT - Brasil

Posted 12 February 2015 - 11:03 PM

I'm looking at the code here.

very creative this idea, is an alternative.

but it would be great this new field, it would facilitate the development, (easy and simple).


  • 0

Best Regards
Marlon Nardi
www.falconsistemas.com.br

 

(Store) https://store.falconsistemas.com.br - HyperServer

(Finance) https://app.falconsistemas.com.br - HyperServer

(Json to Delphi Class) https://jsontodelphi.com


#4 ZigZig

ZigZig

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 340 posts

Posted 12 February 2015 - 11:41 PM

Why don't you use a pointer to a record with TUniTreeNode.Data property? I think that it is the best practice to achieve what you need.


  • 0

#5 Marlon

Marlon

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 378 posts
  • LocationNova Mutum - MT - Brasil

Posted 13 February 2015 - 12:41 PM

Yes it is possible.

if not how to add this new field, I have to go for it.


  • 0

Best Regards
Marlon Nardi
www.falconsistemas.com.br

 

(Store) https://store.falconsistemas.com.br - HyperServer

(Finance) https://app.falconsistemas.com.br - HyperServer

(Json to Delphi Class) https://jsontodelphi.com


#6 ZigZig

ZigZig

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 340 posts

Posted 13 February 2015 - 01:35 PM

Maybe something like that?

Declare a pointer to a record which contains all the fields you need.
 

type
PMyRecord = ^TMyRecord;
TMyRecord = record
MyStringField: String;
MyIntegerField: Integer;
MyDateTimeField: TDateTime;
MyTGUIDField: TGUID;
//...
end;

Assign an instance of this pointer to each node of your tree.
 

var MyRecordPointer:PMyRecord;
MyNode:TUniTreeNode;
begin
//In a loop...
MyNode:=MyUniTreeView.Items.Add(nil, 'myNodeCaption');
New(MyRecordPointer);
MyRecordPointer^.MyStringField:='uniGui';
MyRecordPointer^.MyIntegerField:=99;
MyRecordPointer^.MyDateTimeField:=now;
MyRecordPointer^.MyTGUIDField:=TGUID.Empty;
MyNode.Data:=MyRecordPointer;
//Loop...
end;

Get the values of the record linked to a node whenever you want.
 

ShowMessage(PMyRecord(MyUniTreeView.Selected.Data)^.MyStringField);
DecodeDate(PMyRecord(MyUniTreeView.Items[0].Data)^.MyDateTimeField, MyYear, MyMonth, MyDay);
//...

  • 1

#7 Marlon

Marlon

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 378 posts
  • LocationNova Mutum - MT - Brasil

Posted 13 February 2015 - 04:05 PM

I will do this

thank you. ;)


  • 0

Best Regards
Marlon Nardi
www.falconsistemas.com.br

 

(Store) https://store.falconsistemas.com.br - HyperServer

(Finance) https://app.falconsistemas.com.br - HyperServer

(Json to Delphi Class) https://jsontodelphi.com


#8 Abaksoft

Abaksoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 637 posts
  • LocationAlgeria

Posted 13 February 2015 - 08:09 PM

+1
You can do it also with objects to avoid pointer's records.
TUniTreeNode.Data accept any object :

Type TmyData=Class
Private
fMyString:string;
fMyinteger:integer;
...
published
   Property  MyString : string read fMyString write fMyString;
   Property: integer read fMyinteger write fmyinteger;
end;

Then declare an instance of your object :
Var Obj: TmyData;
Begin
Obj:=TmyData.Create;
Try
Obj.Mystring:='Hello i am Node 1';
Obj.Myinteger:=1001;

// then use Data methode to get it :
--------------------------------------
MyUniTreeView.Selected.Data := Obj;
--------------------------------------
Finally
Obj.free;
End;
 

_________________________________

After you can retreive your fields like : 

 UniEdit1.Text := TmyData(MyUniTreeView.Selected.Data).fMyString;

 UniEdit2.Text := intToStr( TmyData(MyUniTreeView.Selected.Data).fMyInteger );

 

Thx to FreeMan35

 

Regards.


  • 3

#9 ZigZig

ZigZig

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 340 posts

Posted 14 February 2015 - 01:01 PM

Thanks Abaksoft !
  • 0

#10 Freeman35

Freeman35

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 372 posts

Posted 23 September 2016 - 03:27 PM

I'm still testing on trail version, so I can not check source code of unigui. If I'm not wrong, TUniTreeView and TUniTreeNode class inherited from delphi. If this true, why not published some importent properties? example: "OnDeletion" event. This event so usefull for purge memory for added data.

Var Obj: TmyData;
Begin
Obj:= TmyData.Create;
MyUniTreeView.Selected.Data:= Obj;// blocked ram.

and add 20 nodes. this mean created 20 time obj record. after then user delete some nodes. in unigui, have to write some code lines and make many control for memoryleak. But on delphi's treeview, just one line:

....OnDeletion(Sender: TObject; Node: TTreeNode);
TmyData(Node.Data).Free; // simple scenario

Best regards


  • 1

#11 Abaksoft

Abaksoft

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 637 posts
  • LocationAlgeria

Posted 23 September 2016 - 09:26 PM

Hello FreeMan35,

 

You are right :)

http://stackoverflow...eed-to-be-freed

See also having many type of data on a TreeView :

http://stackoverflow...eview-data-type

 

Regards


  • 0

#12 Freeman35

Freeman35

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 372 posts

Posted 24 September 2016 - 08:59 AM

If needed is just store data, (string, integer etc.) I'm not recomended class type. record or packed record is better then class.

My example is:

type  
  P_Data= ^T_Data;
  T_Data = record
    Lst: TList;
    Hint: string;
    whr : string;
  end;
..
var
    N: TUniTreeNode;
    P: P_Data;
begin
      N:= TRW_.Items.AddChild(nil, 'Test node');
      P:= New(P_Data);
      P.Lst:= TList.Create;
      N.Data:= P;
     
     P.Lst.Add(TUniCheckBox.Create(FRM_xxxx);

This my usage. before remove data, in  Lst's (TList) dimision has to be free, then free node data (record) via dispose(P); this can be so easy, if ondeletion event be added.


  • 0

#13 Phxtecno

Phxtecno

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 66 posts

Posted 27 October 2016 - 08:00 PM

About feature request,

I'd like have the possibility to Bookmark the most interesting/useful forum topics in my profile

so I have my personal Wiki to look at when I need remember how problems can be solved.

 

It's a forum feature I have seen very useful on other products (RemObjects).

 

Thanks


  • 0





Also tagged with one or more of these keywords: TUniTreewView

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users