View previous topic :: View next topic |
Author |
Message |
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Mon Jul 14, 2008 8:10 pm Post subject: Editing Lookup Text |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jul 14, 2008 10:19 pm Post subject: |
|
|
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 |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Tue Jul 15, 2008 1:03 am Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jul 15, 2008 9:14 am Post subject: |
|
|
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 |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Tue Jul 15, 2008 6:46 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jul 15, 2008 10:58 pm Post subject: |
|
|
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 |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Tue Jul 15, 2008 11:22 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jul 16, 2008 6:07 am Post subject: |
|
|
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 |
|
|
|