none
Programmatically toggle between query data sets in an autocomplete box

    Question

  • I have a LS app that connects to a large database (>5000 rows) of ICD-9 disease diagnosis codes and descriptions.  Because many of the ICD-9 codes are esoteric, I designed the entity set to include a boolean property of "common" diagnoses, which is much shorter.

    On the screen, the user selects via an autocomplete box the ICD-9 code needed.  I would like the user to be able to toggle between the complete ICD-9 list and the filtered "common" list by selecting a button-generated method that I include in the C# code-behind.

    I know how to create individual ACB controls for either the complete ICD-9 list or the "common" codes by constructing a query and selecting the relevant property on the ACB for either list.  What I want to do is have one ACB control that can toggle between either the query-filtered common code versus the complete list depending on the user's preference.

    Any suggestions?

    vendredi 1 mars 2013 18:40

Réponses

  • What you can do is create a query that takes a parameter that determines whether to allow only common codes or all codes. For example:

    In your screen, add a new data item based on this query (I called it ICD9CodesFiltered). Set the Choices property of the Auto Complete Box to this newly created property. Select the query parameter (I called it CommonCodesOnly in my query) and drag it out onto the screen near your Auto Complete Box. This will generated a new screen member (it is called CommonCodesOnly) to which the query parameter is bound and a check box where you dragged out the query parameter. Finally, in your screen's Created event, set the CommonCodesOnly property on the screen to the default value you'd like (true to show only the common codes; false to show all codes). This should achieve the functionality you are looking for.

    Instead of using the check box, you could always put in a button that toggles the value of CommonCodesOnly and updates its own display name based on the new value, if you really want a "toggle" button.


    Justin Anderson, LightSwitch Development Team

    samedi 2 mars 2013 09:36

Toutes les réponses

  • What you can do is create a query that takes a parameter that determines whether to allow only common codes or all codes. For example:

    In your screen, add a new data item based on this query (I called it ICD9CodesFiltered). Set the Choices property of the Auto Complete Box to this newly created property. Select the query parameter (I called it CommonCodesOnly in my query) and drag it out onto the screen near your Auto Complete Box. This will generated a new screen member (it is called CommonCodesOnly) to which the query parameter is bound and a check box where you dragged out the query parameter. Finally, in your screen's Created event, set the CommonCodesOnly property on the screen to the default value you'd like (true to show only the common codes; false to show all codes). This should achieve the functionality you are looking for.

    Instead of using the check box, you could always put in a button that toggles the value of CommonCodesOnly and updates its own display name based on the new value, if you really want a "toggle" button.


    Justin Anderson, LightSwitch Development Team

    samedi 2 mars 2013 09:36
  • That worked nicely, thanks so much.

    To my surprise, though, all I really needed was to pass the parameterized query "IsCommon=@CommonCodesOnly" to make it work.  The IsCommon=true was superfluous for this function.

    The check box control was fine, writing a special button method would not have improved the UI so I abandoned it.

    samedi 2 mars 2013 20:09
  • The IsCommon = True filter is needed when CommonCodesOnly is false, because if that filter is not used, then entities with IsCommon set to true will be filtered out of the result set. You asked for having a complete list versus common only list, so having IsCommon = True filter allows for the list to be complete in the case where CommonCodesOnly is false.

    Justin Anderson, LightSwitch Development Team

    lundi 4 mars 2013 10:00