Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Delphi For PHP > VCL4PHP
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

VCL4PHP VCL for PHP. Questions or comments about the Visual Component Library for PHP, post them here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11th December 2009, 02:00
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 63
dalyla is on a distinguished road
Default New CheckBox Treeview

Hello I'm making a Checkbox Treeview as a new component. I wasn't stopped in just add images to the treeview because I need Parent node check or uncheck childs. And if all childs are the same way parent too, or if there are diferent like a child checked and another not, parent turns grayed. This last doesn't have a normal combobox.

At this moment I get an error Cannot unserialize without owner or something like that.

PHP Code:
<?php
require_once("vcl/vcl.inc.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("imglist.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");



//Class definition
class TreeViewCheckBox extends treeView
{   function getImageList()                 { return $this->readImageList(); }
    function 
setImageList($value)           { $this->writeImageList($value); }

    function 
__construct($aowner null)
    {
    
parent::__construct($aowner);

    
$IconsList = new ImageList();
    
$IconsList->setImages(array ( => "unchecked.jpg"=> "grayed.jpg"=> "checked.jpg" ) );
    
$this->ImageList $IconsList;
    
//$this->SetValueCheckBox();
    
}

    function 
dumpContents()
    {
    
parent::dumpContents();
    }

    function 
SetValueCheckBox()
    {
    
$Node $this->findNodeWithItemID($this->SelectedItemID);
    if(
$Node != null)
      if(
$Node->SelectedIndex == 1)
         
$Node->SelectedIndex 3;
      else
         
$Node->SelectedIndex 1;

    
$this->EquateChildren($this->findNodeWithItemID($this->SelectedItemID));
    
$this->UpdateNode($Node->ParentNode);
    }

    function 
UpdateNode($Node)
    {
    if(
Assigned($Node))
        {
        
$Count 0;
        
$Weight 0;
        
$i 0;
        
$Child $Node->Items[$i];
        while(
Assigned($Child))
            {
            
$Child $Node->Items[$i];
            
$Weight $Weight + ($Child->ImageIndex 1);
            
$Count++;
            
$i++;
            }

        if(
$Weight )
            
$Node->ImageIndex 1;
        elseif(
$Weight < ($Count))
            
$Node->ImageIndex 2;
        else
            
$Node->ImageIndex 3;

        if(
$Node->ParentNode != Null)
            
$this->UpdateNode($Node->ParentNode);
        }
    }

    function 
EquateChildren($Node null)
    {
    
$i 0;
    
$Child $Node->Items[$i];
    while(
Assigned($Child))
        {
        
$Child->ImageIndex $Node->ImageIndex;
        
$this->EquateChildren($Child);
        
$i++;
        
$Child $Node->Items[$i];
        }
    }
}

?>
Also the component doesn't show right in the design time. If I remove the images parts it show correctly, so it is well instaled. But has errors.

Another thing I don't know is how to catch php click, it just has a jsclick, and I need it to call Equatechildren and update nodes.

thanks in advance
__________________
My world seems to be shinin'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11th December 2009, 04:38
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,268
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

I think php click would be very inefficient. (and unbearable)

What you want to do is use js click and set a hidden field to use later with php.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11th December 2009, 20:06
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 63
dalyla is on a distinguished road
Default

Well this is my first component and I'm not sure how to do it. I know I have 2 problems, how to set those two new functions, and why appears this error:

Application raised an exception class Exception with message 'Cannot unserialize a component without an owner'

This last is a problem because I can't continue without solve it. I don't understand it, I think my component has an owner. The image list its owner is my treeview I guess. I can't identify which one is without owner.

What you say i'll probe it after solve this, because now i can't :P

thanks
__________________
My world seems to be shinin'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11th December 2009, 20:22
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 63
dalyla is on a distinguished road
Default

The error of unserialize come from a function LoadFromResource this function loads a component from a string I think it has to be with something wrong declaring my ImageList. Or lack of something.

**

About this I added this line in the construct

PHP Code:
$IconsList->owner $this
Maybe this isn't the right declaration I don't know but now I can see my component.

Now I need to know how to call the other 2 functions
__________________
My world seems to be shinin'

Last edited by dalyla; 11th December 2009 at 20:28.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 13th December 2009, 15:29
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,268
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Quote:
Now I need to know how to call the other 2 functions
When do you need to call them?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 17th December 2009, 02:27
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 63
dalyla is on a distinguished road
Default

Well, everytime when is checked or unchecked a node
__________________
My world seems to be shinin'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 17th December 2009, 13:36
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,268
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

I don't know what those functions are doing but it isn't practical to do something in php everytime someone checks a box unless it is forcing the page to do a big change.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 18th December 2009, 01:37
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 63
dalyla is on a distinguished road
Default

If you

[] 1
|-[] 1.1
|-[] 1.2
|-[] 1.3

if you click 1.1, as child of 1, 1 is grayed telling every one, at least I have one child checked.

[#] 1
|-[*] 1.1
|-[] 1.2
|-[] 1.3

But if all childrens are checked, father is checked normally, and it's saying All my children are checked. And if all childrens are unchecked father too, saying all my children are unchecked. So if I change a child y have to change father, and if I change father I have to change children.

And this code works I know because I probe it with a button, but i can't click tree and a button
__________________
My world seems to be shinin'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 18th December 2009, 03:32
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,268
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Like I have been saying - IMO you need to do this in js and not php. php is not practical.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 21st December 2009, 21:37
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 63
dalyla is on a distinguished road
Default

Ok, I'm following what you said,
I don't get how to change the image index in javascript. It's more difficult because is qooxo, how I can get the properties?
__________________
My world seems to be shinin'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 10:38.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use