none
Can I modify the contents of a combo based on the currently selected item in a master-details screen?

    Question

  • Sorry if the title wasn't very clear, but it was a bit hard to explain in one line! The situation is quite simple, I have a list of categories, and each category has a ParentCategory property, which is either null (ie a top-level category), or is set to another category.

    I have a master-details screen, where users can add and edit categories. When they edit a category, the combo for the ParentCategory property is populated with all possible categories, including the current one. This means that they can set the category's parent to the category itself, which I want to prevent.

    I know I can add a validation rule to catch this, but it would be much neater if I could simply filter the list of categories to exclude the current one, so they simply can't make this mistake.

    Any idea how this can be done?

    Thanks


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Monday, August 29, 2011 2:26 PM

All replies

  • If you haven't find any solution yet, try JaimeH's idea. You may need to create a query on your category table that eliminate, selected category. 

    http://code.msdn.microsoft.com/A-way-to-handle-a-simple-dbba9ff1


    -Bala
    Tuesday, August 30, 2011 3:19 PM
  • Thanks, it looks like it does what I want, but I can't say I understand what he did. I'm going to need some careful reading to try and work it out.

    For me, this sort of thing is the one area where LS is really lacking. It looks like you can do all sorts of clever stuff if you know how, but it's extremely difficult to find any clear explanation of what and how. There are loads of beginner's videos, and some advanced stuff, but most of the latter only show you what to do, they don't actually explain what's going on. I'm finding it quite tough to get my head around a lot of things that would probably be quite straightforward, given a decent explanation.

    Anyway, enough ranting. Thanks for the link. I'll have a closer look and see.


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Tuesday, August 30, 2011 3:26 PM
  • Believe me.. I had this frustration when I was working with Beta 1/2. I even quit LS for sometime and moved to Web Dev for last several months. :)

    Of course even now I'm getting frustration with LS, but at the same time, we can't expect the software should work 100% the way we want.  When I kept complaining abt LS, the community went ahead and created some wonderful extensions, themes, controls, workarounds and many more.  So I decided to stop complaining and started to look how to overcome with it.

    LS is one of the best thing happened in my life. Trust me!! :) Once you get the concept of it, you sure you'll feel that too! :)

    Anyway, if I have time to play with ur question, I'll try to create a sample for you, but running on a tight schedule. :) Will try my best. ;)


    -Bala
    Tuesday, August 30, 2011 3:35 PM
  • Thanks very much!

    I know what you mean about the frustration, but I'm not giving up on LS. I just need to get more experience. The people in this forum are great, and I'm learning a lot as I go along, but there are so many little gotchas that I keep finding. I just wish someone would produce a good in-depth book on LS. I know Yann is working on one right now, I just hope he gets it done soon!

    Even with all the problems, I am producing a working app in a fraction of the time it would have taken before.


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Tuesday, August 30, 2011 4:31 PM
  • Mr Yossu,

     

    I was able to pull a small sample for your need, based on JaimeH's example. You don't have to follow all his steps on the tutorial for your requirement (I guess).

     

    However there is a 'gotcha' that, when you create a new Category on the "Editable Grid Screen", then that will show up on the "Auto Complete Drop Down" which is a known issue. Check this thread for more info : http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/6c5272d5-f619-48df-88a5-f3e16672ad88

     

    So what I did was,

    1. Create a Editable Screen Just for "Category Name" and removed the "ParentID" field.

    2. Added few Categories

    3. Create another "List and Details Screen", and now I select one Category and select its "Parent", which doesn't include the selected Category on the Drop down.

     

    Do you think this'll work for you?


    -Bala
    Tuesday, August 30, 2011 6:07 PM
  • Here I composed a small walk through for your ref. Hope this helps.

     

    http://powerbala.com/2011/08/30/selfcircular-reference-in-lightswitch/ 


    -Bala
    Wednesday, August 31, 2011 4:38 AM
  • Thanks very much! I haven't time right now, but will definitely look at that one later.
    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Wednesday, August 31, 2011 3:47 PM
  • OK, I had a look at that, and it seems fairly clear. However, as the main time my users will be choosing the parent is when they create a category, it isn't really going to help me. As you point out at the end, you need to save the data before the filter will work. For example, if you click the plus button on the list detail screen, and type a category name in the top box, then when you open the drop down to see the categories, your new name appears in the list.

    It looks like there isn't a way around this, unless you have some other ideas.

    Thanks very much again for the help.


    If you're really bored, you could read about my experiments with .NET and some of Microsoft's newer technologies at http://dotnetwhatnot.pixata.co.uk/
    Wednesday, August 31, 2011 5:13 PM