Unigui Trial Notes (14) Tunitreeview checkbox

Source: Internet
Author: User

The current version of Tunitreeview does not encapsulate the checkbox function, so it needs to be processed manually, fortunately the version 0.99 provides some code, the modification process is as follows:

1, the Uniguiabstractclasses.pas unit modifies the base class Tunitreenode, increases the checked attribute, the code is as follows:

Tunitreenode  class(tpersistent)  private    Fchecked:boolean;    ...    Public     Property Read Write fchecked;   End;

2, modify the Tunitreeview class in the Uniguisource\unitreeview.pas unit, add the support attribute to the checkbox, the code is as follows:

Tunitreeview  class(Tunicontrol, Iunitreeview)  private    Fusecheckbox: Boolean;  ...   published     Property Read Write Fusecheckbox; End;

3, the Uniguisource\unitreeview.pas unit modifies the Twebtreenode class, the JS code generation part adds the support to the checkbox, the code is as follows:

functionTwebtreenode.tojson (Aexpanded:boolean = False):string;varImgurl:string; I:integer;beginImgurl:=Getimageurl (Fimageindex); Result:='{ID: "'+inttostr (FID) +'"'+Ifthen (Text<>"',', Text:'+ STRTOJS (Text)) +//If the TreeView supports the checkbox is displayed, the default false====================Ifthen (Fparenttree.usecheckbox,', checked:'+ Ifthen (Checked,'true','false'))+//=================================================imgurl+Ifthen (fexpandedorAexpanded,', Expanded:true')+Ifthen (Childnodes.count=0,', Leaf:true')+Ifthen ( notFenabled,', Disabled:true'); ...End;

4, the Uniguisource\unitreeview.pas unit modifies the Tunitreeview class Webcreate method, to its JS code generation part joins to the checkbox processing, the code is as follows:

proceduretunitreeview.webcreate;begin  ...  //adding a processing code to a checkboxJscode ('changechecked:function (node, checked) {'+//If the node is an array, such as Node.childnodes, the loop recursively handles each child node      'if (Ext.isarray (node)) {'+'For (var i=node.length-1;i>=0;i--)'+'this.changechecked (Node[i], checked);}'+'else{'+//determine if the checked attribute exists and change if it exists      'if (node.data.checked!=null)'+'{node.set ("checked", checked);}'+//If the node is a parent node, the recursive call processes the subordinate nodes      'if (node.childnodes.length>0)'+'{this.changechecked (node.childnodes, checked);}'+'}'+//For Else    '}');//For functionEnd;

5. In the clientevents attribute of Tunitreeview, set the Checkchange event in extevents with the following code:

function Checkchange (node, checked, eopts) {  if (node.childNodes.length > 0)    this  . changechecked (node.childnodes, checked);}

In this way, the basic performance requirements, there are the following issues need to be further resolved:

1, the interface has changed, but node's checked attribute has not changed, also did not trigger related events;

2. The 5th step should be resolved in the class of the control, but no workaround is found and is currently temporarily written in the form control properties.

Unigui Trial Notes (14) Tunitreeview checkbox

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.