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 

Editing Lookup Text

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



Joined: 27 Jan 2008
Posts: 43

PostPosted: Mon Jul 14, 2008 8:10 pm    Post subject: Editing Lookup Text Reply with quote

When I apply a univeralEditBox editor to a LookupField, I get a list, so I can select a different lookup value.

I actually want to be able to change the text of a LookupField (i.e., modify the lookup table itself).

Can I configure an editor or handle a "SetData" event to do this?

Thanks.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jul 14, 2008 10:19 pm    Post subject: Reply with quote

There are a few different ways to achieve this. When you set a field to be a lookup field it uses a special TypeConverter and UIEditor for that cell in Virtual Tree. You could create your own TypeConverter (which converts the data to a string) and editor (which allows selection) and set these in the GetCellData event handler.

Alternatively (and possibly easier) is to create your own editor derived from a VirtualDropDownList control and override the GetTextForItem method to return the text you want for the given item.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jaherbert



Joined: 27 Jan 2008
Posts: 43

PostPosted: Tue Jul 15, 2008 1:03 am    Post subject: Reply with quote

Thanks. Actually, I don't need the "lookup" functionality. That is, I don't need to be able to select a different value from the list. There's a 1:1 relation between the ID field and the lookup text. Prior to wanting to edit it in place, I was using the lookup as a mere translator.

So, it looks to me like I can use a UniversalEditBox and GetCellData (to do the lookup and set cellData.Value) and SetCellValue (to store e.NewValue in DataSet).

Two problems:

1. It doesn't get the sort column right.
2. Change notifications don't seem to work. I change the name on via another control and I don't see it on the VT. I imagine it's subscribed to changes on the id, not the name.

Both of these things worked with a lookup field.

If you're recommending using a custom derived an editor, do you have any code samples for how to hook it up properly.

Thanks again.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jul 15, 2008 9:14 am    Post subject: Reply with quote

I think I understand what you are saying. You don't want to select values from a list of possible values - merely display the current value (from a linked table) and possibly allow the user to change the text for the current value in the linked table. Is that right?

For this you can use a simple TextBox as the editor and and handle the GetCellData and SetCellValue events as you are doing.

Quote:
1. It doesn't get the sort column right.


This is actually an underlying issue with DataSets that don't support sorting via a related column in another table. The data can be sorted on the column - but the sort order will be based on the id number - not the text in the related column. I don't think this would have worked using lookup fields either.

Quote:
2. Change notifications don't seem to work. I change the name on via another control and I don't see it on the VT. I imagine it's subscribed to changes on the id, not the name.


That's correct - you'd need to call UpdateRowData youself when the associated text is changed.

Another possibility may be to do a join when you load the data in the dataset and load both the id for this field and the text. Then you can display the text and sort will work correctly - as will editing. The only issue then will be resolving those changes back into the database (I'm assuming you are using a database). That could be tricky. It may be worth posting a question on the ADO.NET newsgroups.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jaherbert



Joined: 27 Jan 2008
Posts: 43

PostPosted: Tue Jul 15, 2008 6:46 pm    Post subject: Reply with quote

Thanks. I understand about notifications. Re: sorting, I guess other controls which offer this kind of feature, manage the sort within the control. Is this something you intend to add?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jul 15, 2008 10:58 pm    Post subject: Reply with quote

Quote:
Re: sorting, I guess other controls which offer this kind of feature, manage the sort within the control. Is this something you intend to add?


The only way to implement sorting in the control (as opposed to in the DataSource) is to iterate through the entire data source list. This would negate Virtual Trees ability to display large data sources efficiently and quickly. It is still possible to do this if you want to by handling the GetChildren event and doing the sorting yourself (returning DataRows)
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
jaherbert



Joined: 27 Jan 2008
Posts: 43

PostPosted: Tue Jul 15, 2008 11:22 pm    Post subject: Reply with quote

Right I can handle that in GetChilden. I was thinking about clicking the column to sort and it sorting only those rows for which it has already built an internal representation.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jul 16, 2008 6:07 am    Post subject: Reply with quote

Quote:
I was thinking about clicking the column to sort and it sorting only those rows for which it has already built an internal representation.


As Virtual Tree only builds an internal representation for those rows which are actually displayed, this would not be very useful. For instance with a tree containing 1000 items under the root only the first 50 or so may be displayed initially (and so have an internal representation). Sorting only the first fifty would not be what the user is expecting when clicking on the column header.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
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