Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Add columns with lookup values from id fields in objectlist
posted

 Good evening folks, I'm new here and I hope someone can give me some extra insight into my current situation.

I'll try and be as complete and to the point as possible in describing my situation.

Basically I have a Windows Form UltraWinGrid which I'm populating with List<T>, however, I wish to replace several id-fields by their respective description fields.

Let's scetch my situation with a simple example.

Say I have a List<Customer> and the Customer class includes the usual properties like name, first name, birth date, ...
But also various id fields. The Customer class is a object that gets it's data filled from OR mapping from a persistent storage medium, in my case that's a

SQLServer2005 database, the id fields are basically the relationship fields from the database. Basically Customer object is pretty much an object representation of the persistent table.

So for example:
public class Customer
{
    String name, firstName, PhoneNumber, ...
    int customerId, favColorId, livingPlaceId
}

public class FavoriteColors
{
    int favColorId
    string colorName, hexNotation, string RGBNotation
}

public class LivingPlace
{
    int livingPlaceId
    string country, city, countryCode, postalCode
}

So I have a List<Customer> customers and bind it to my grid in code behind as 'customersGrid.Datasource = customers'
This works fine and my whole system has already been programmed around working like this. So for functionality there's no problem. After all, it's the id values that are used for the programmatic identifying and so on.
However like this I display values to the user that he wouldn't really understand as the first record would for example be
CustId    Name    FirstName    Phone    FavColorId    LivingPlaceId
1            Me         Me Again     2211            1                    1

So when displaying the grid I would like FavColorId to be replaced with it's colorName with that Id. The same for livingPlace, I'd want the grid to show country for

example with that stored id.
For this example let's assume the values are stored in a List<FavoriteColors> and a List<LivingPlace>.

That's what I'm seeking to accomplish in a nutshell.
I was thinking of adding an unbound column for each id-field (in code) after setting the datasource to customers (haven't looked it up yet, but that should be possible right?), and afterward I'd go through the whole grid with a foreach(UltraGridRow in grid) loop, filling the unbound columns with the looked-up data.
And then I'd hide the columns that the user doesn't actually need to see.
However, I suppose that'll be rather performance ineffective, so was wondering what you folks think of this.

Ok, I think that's about it.

Parents Reply
  • 305
    posted in reply to Mike Saltzman

    Mike,

     While, waiting for your reply, I continued my search for alternate methods, and found the following code in one of your knowledge base articles:

    http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=1035

    So I followed the technique:

     1. Instance a new ValueList with in a grid; 2. add items to the value list.; 3.  assign the list to a column within a band; and lastly;  4. set the ValueList display style.

    Might I add, the original How To article referenced in this thread, fails to mention Step 4, setting the display style, within the paragraph concerning value lists.  It is a little annoying to find two articles on the same subject that are not consistant with each other.  You would hate to be that sorry developer who pulls their hair out because they read the article that didn't give them all the correct code in the sample provided.

    Anyway, not that it matters, neither code works,  Same result.  The desired List Values are not being displayed.  No errors or exceptions are being thrown.

    I don't believe a "small sample project" would suffice as it wout take the code out of context.  It would seem that a property setting or method being called is in conflict with the use of a ValueList, althought such is not easily identifiable, as it does not create an error.  I would need to show you everything that I am doing to the grid so that the proper test conditions are replicated.  Not that I have time for this nonsense, but I suppose it is the only way I'll get an answer.

Children