Jump to content

flag parent when child is checked, UniTreeView with checkbox


fiorilli

Recommended Posts

5 hours ago, fiorilli said:

Hello, I am using UniTreeView and I noticed that when check only one of several children the father does not receive a "flag". Would you have any solution for this case? Example Below

Hello,

I have faced this issue before, but I didn’t save the solution seems.

This post may help you:

 

Link to comment
Share on other sites

  • 2 weeks later...

 

Hello, thanks for the help. The post that passed me helped a lot. some changes were needed as my tree was over 1 level. I am posting below my code for future reference.

javascript:

function checkchange(node, checked, e, eOpts)
{ function SetNodeChecked(mynode, c)
  { mynode.removeCls('ThirdStateNode');
    mynode.set('checked', c);
    if (mynode.hasChildNodes())
    { for (var i=0; i<mynode.childNodes.length; i++) 
      { SetNodeChecked(mynode.childNodes, c);}
    }
  };
  function setpNodeChecked(node)
  { function getpNodeChecked(node)
    {var mynode=node.parentNode;
     for (var j=0,k=0; j<mynode.childNodes.length; j++)
     { if (mynode.childNodes[j].data.checked) {k++;}; };
     if (k==0) {return 0;} if (k==mynode.childNodes.length) {return 1}; return 3;
    }
    if (node.parentNode.data.id!='root')
    {var pNode=node.parentNode,vv=getpNodeChecked(node);
     var pp=Ext.get(Ext.getDom(fPerfil.UniTreeView1.id).getElementsByTagName('div')[pNode.data.id]);
     if (vv==0) 
     {pNode.set('checked',false);
      pNode.removeCls('ThirdStateNode');
     }
     if (vv==1) 
     {pNode.set('checked',true);
      pNode.removeCls('ThirdStateNode');
     }
     if (vv==3) 
     {vv=1;
      pNode.set('checked',true);
      pNode.addCls('ThirdStateNode');
     }
     setpNodeChecked(node.parentNode);
    }     
  };
  SetNodeChecked(node,checked);
  setpNodeChecked(node);
}

 

css: 

//Here is inserted a new image that was made based on the unigui standard image located at:  FMSoft \ Framework \ uniGUI \ ext-6.7.0 \ build \ classic \ theme-neptune-touch \ resources \ theme-neptune \ images \ form \ checkbox.png

.x-tree-checkbox{
    background-image: url("../imgs/tree/Terceiro-Estado.png");
}

//here is linked to the div of the node representing the button or the new background position.

.ThirdStateNode div[role="button"] {
  background-position: 0 -30px !important;
}

Final result below.


 

Capturar.PNG

  • Like 1
Link to comment
Share on other sites

On 12/27/2019 at 4:27 PM, Sherzod said:

Thank you

 
 
hello sherzod, 
after solving this case I came across another problem. 
This treeview will be used to display the permissions of each user. 
So when I change a user I need him to load the database information. So I need to check the nodes by code. 
I try to use JSCallDefer, though, he says he can't find my function. 
any ideas to solve this case?
Examples below:

UniTreeView1.JSInterface.JSCallDefer('checkchange', [Node, checked], 20);

 

Taking advantage of the case, I realized that UniTreeNodes has no JSid or JSName, how do I pass them as
parameters or do client-side state checks?

 

error image: 

Capturar.PNG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...