Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to change RowChildPolicy for selected items

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Thu Mar 19, 2009 6:14 pm    Post subject: How to change RowChildPolicy for selected items Reply with quote

My tree uses design time binding.
I am setting RowChildPolicy to Normal when tree initially shows items.
Its too slow if I set to LoadOnExpand, even though I have optimized things.
So now I have a command to "Get rid of + signs for items with no children", but I am not sure how to do this.

I am overriding GetChildPolicyForRow in my tree code.
This sets RowChildPolicy for all rows, but I want to change it later for just some rows.
here is code as is:

protected override RowChildPolicy GetChildPolicyForRow(Row row)
{
//tweak mode based on children or not
//too slow currently so commented out

//if (row.Item is XreVDwg) {
// if ((row.Item as XreVDwg).IsXreffed == true)
// return RowChildPolicy.LoadOnExpand;
// else
// return RowChildPolicy.Normal;
//}
//else {
// return RowChildPolicy.LoadOnExpand;
//}

return RowChildPolicy.LoadOnExpand;
}

It seems to me that the only way would be to modify this to check if an item is part of some list of items that are supposed to have their + signs weeded, then redisplay all the data on the tree.
That would be like setting a filter for what should always be LoadOnExpand, and what should be either LoadOnExpand or Normal.

Ideally though, I could set a bool var that told the GetChildPolicyForRow to look at IsXreffed and then just redisplay the selected items.
I'll try that but wanted to ask if there is some better way to do this.
_________________
James M
Back to top
View user's profile Send private message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Thu Mar 19, 2009 6:56 pm    Post subject: Reply with quote

I did the boolean flag and that worked fine.
I see now that I really have to do something to speed up the info gathering for items that do have kids.

It seems like this would be a super common issue (and is from the other posts) that could be solved with a third RowChildPolicy value of "NormalWithDelayedLoad" or something.
This would essentially be saying to show the +, but do not gather the child data yet.
It would only be useful for someone overriding the GetChildPolicyForRow event and would allow the programmer to decide if the + sign shows, without the vtree grabbing its kids to decide.

I think the workaround is to use the expand event to catch when an items kids really need to show, and use dummy kids before that.
_________________
James M
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Mar 19, 2009 9:42 pm    Post subject: Reply with quote

jmaeding wrote:
It seems like this would be a super common issue (and is from the other posts) that could be solved with a third RowChildPolicy value of "NormalWithDelayedLoad" or something.
This would essentially be saying to show the +, but do not gather the child data yet.


This is exactly what the RowChildPolicy.LoadOnExpand option does. The downside is that because it delays getting the children for the row it does not know whether the + sign should be displayed - hence it displays the + initially (which may then disappear when the row is expanded if their are no children). If getting children is expensive and you can determine that a given row does not have children, without having to actually get the children, then you can override the GetChildPolicyForRow method and return RowChildPolicy.Normal for this Row. You may also need to override the GetChildrenForRow method and return null for this row - to avoid the expense of actually retrieving children when there are none.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Fri Mar 20, 2009 3:31 pm    Post subject: Reply with quote

I did override the getchildrenforrow and it was still too slow because the items that did have kids slowed it down too much.
Its like I need a way to show the + sign based on a property of the parent object so the prog does not even check if kids are present.

What I am trying now is to return a dummy child for items that have real children, then later switch out the dummy for real kids when the item is expanded.
That still costs a little but I think its the best I can do for now. I'll report back if it works.
_________________
James M
Back to top
View user's profile Send private message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Fri Mar 20, 2009 6:48 pm    Post subject: Reply with quote

I think I am saying this the wrong way.
What I need is a way to supress the + sign if desired.
Right now, I can force the + sign to show by setting loadondemad.
I cannot supress it without making the program look for kids.

Part of the issue is on my end, as looking for kids is too slow, but I do know if i need to look for kids or not based on a flag in the parent object so would like to bypass the kid searching altogether and supress the +.
_________________
James M
Back to top
View user's profile Send private message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Fri Mar 20, 2009 7:49 pm    Post subject: Reply with quote

oh, just realized what you mean, to supress +, simply return null from getkids funtion, duh.
thx
_________________
James M
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group