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
530
Best practice for variable dropdown within grid
posted

Say you have the following tables representing customers and their accounts...

 CustomerId          CustomerName
--------------------------------------------------------------
1                         ABC Company
2.                        XYZ Company

AccountId            CustomerId           AccountName
----------------------------------------------------------------------------------------------
1                         1                         Account 001
2                         1                         Account 002
3                         2                         Account 003
4                         2                         Account 004
5                         2                         Account 005

So, as you can see customer #2 has three possible accounts and customer #1 has two.  I have a grid with two dropdown columns.  When the account field is entered I can catch the event and filter my data source to exclude accounts that don't belong to the current customer.  Unfortunately, since I just filtered out records that are referenced by other rows in the grid they revert to showing the primary key rather than the name.  That behavior makes perfect sense, the question is what is the best practice when you have a situation like this?   Are there any built-in events or methods that I could use to dynamically adjust the dropdown values on a row-by-row basis without affecting other rows? 

  • 469350
    Verified Answer
    Offline posted

    The way to handle something like this is - don't use the same ValueList for the entire column. You should create a ValueList for each possible list and assign the ValueList to the cells that apply. You would set the ValueList property on the cell inside the InitializeRow event of the grid.