CodePudding user response:
CodePudding user response:
Write a demo which god give me a lookCodePudding user response:
CxTreeList1. The Clear;CxTreeList1. OptionsView. CheckGroups:=true;
CxTreeList1. Root. CheckGroupType:=ncgCheckGroup;
Try
QryParent. DisableControls;
With qryParent do
The begin
The Close;
SQL. Text:='Select * from R_Permission where PARENTID=' '0' ';
The Open;
QryParent. First;
While not qryParent. Eof do
The begin
RootNode:=cxTreeList1. Add;
RootNode. CheckGroupType:=ncgCheckGroup;
RootNode. Values [0] :=qryParent FieldByName (' ID '.) AsString + ' '+ qryParent. FieldByName (' name'). AsString;
RootNode. Values [1] :=qryParent FieldByName (' ID '.) AsString;
//RootNode. ImageIndex:=0;
//RootNode. Enabled:=False;
QryChild. DisableControls;
QryChild. Close;
QryChild. SQL. Text:='Select * from R_Permission where PARENTID=: PARENTID';
QryChild. The Parameters. ParamByName (" PARENTID "). The Value:=qryParent. FieldByName (' ID '.) AsString;
QryChild. Open;
//Filtered:=False;
//Filter:="ID=" + QuotedStr (qryChild. FieldByName (' ID '.) AsString) are identical.
//Filtered:=True;
QryChild. First;
While not qryChild. Eof do
The begin
SonNode:=RootNode. AddChild;
SonNode. Values [0] :=trim (qryChild. FieldByName (' ID '.) AsString) are identical + ' '+ qryChild. FieldByName (' name'). AsString;
SonNode. Values [1] :=qryParent FieldByName (' ID '.) AsString;
SonNode. ImageIndex:=1;
QryChild. Next;
end;
QryChild. EnableControls;
QryParent. Next;
end;
QryParent. EnableControls;
end;
The finally
CxTreeList1. FullExpand;
end;
CodePudding user response:
Your SQL and prone to problemsCodePudding user response:
//is according to the tree structure to store the Items, simply iterate through the Items and get only the first layer of the node//TcxTreeList contains a AbsoluteItems, preserves the order of the structure of the node
For I:=0 to cxTreeList1 - & gt; Do AbsoluteCount - 1
ShowMessage (cxTreeList1 AbsoluteItems [I] Texts [1]).
CodePudding user response:
Fifth floor truth!!!!!!