Radio Button like Functionality between table entries RRS feed

  • Question

  • Radio Button like Functionality between table entries

    The current situation

    I have a related table which holds shift times. Those times are needed when I export to excel the medication orders so that I can have =cell functions display what times the shifts are and show them in the color code key. So I related shift time to medication orders so that the summary property of shift times (Shift type ie "8 Hour Shift") would pull forward all of the other fields in the row for that shift type each a new order was added. I then could add them as other screen data to the medication orders review tab. Knowing where in my grid those times show up I can pull them from the exported foreign excel file cells into the template file cells.

    In order to set a default value for this related table’s summary property on the orders table I have to set up a query. Right now I have a field I call "DefaultShiftSchedule" on the shift times table with a choice list that has two options "Default for Med Orders" and "Not Default for Orders"(Fig 1.1). A query set up on the shift times like this query name= "ShiftTimeDefault" filter where DefaultShiftSchedule = literal “Default for Med Orders”. In the created code for the orders table I have the code this.ShiftTime = this.DataWorkspace.ApplicationData.ShiftTimeDefault();. I setup the summary property as a label not a modal window picker or an autocomplete box. I had to cheat a little to do this by make the control type a picture with text and only including the title text of Shift Type.

    The Problem

    The problem I want to solve is that I want to make DefaultShiftSchedule not a but a Boolean with a check box and somehow make it so that only one line of field entities for the whole table can be marked as the default kind of like a radio button.

    A. I already tried using required Boolean values and it causes errors with my default value query because it is still possible for more than one entry to be true or for none to be true. This causes issues with the designs query model that then defines a default value for entering new orders. (Fig 1.2).

    B. I have no idea how to write control code between entries of the same field on multiple lines of a table or if this kind of radio button like code is possible.

    (Fig 1.1)

    (Fig 1.2)

    • Edited by reigh7 Thursday, September 26, 2013 10:16 PM
    Thursday, September 26, 2013 10:11 PM

All replies

  • Check out How To Enable Multiple Row Selection In LightSwitch's Grids as well as Elyl's Extensions for radio button selectors in LightSwitch. 

    If that is too much coding or doesn't do the trick, ComponentOne's FlexGrid for LightSwitch also may be of help.

    Friday, September 27, 2013 12:00 AM
  • I am
    working through the first example  How To Enable Multiple Row Selection In LightSwitch's
     but I get an error with the last line.
    "_itemsControl.SelectionChanged += newSelectionChangedEventHandler(ItemsControl_SelectionChanged);"

    Where "(ItemsControl_SelectionChanged)" tells me "does not exist in the current context.

    My full code is…

    using System;

    using System.Linq;

    using System.IO;

    using System.IO.IsolatedStorage;

    using System.Collections.Generic;

    using Microsoft.LightSwitch;

    using Microsoft.LightSwitch.Framework.Client;

    using Microsoft.LightSwitch.Presentation;

    using Microsoft.LightSwitch.Presentation.Extensions;

    //we need this to be able to use DataGrid in our code 

    using System.Windows.Controls;


    namespace LightSwitchApplication


        public class DemoItemList


            //although not strictly necessary for this small example 

            //it's good practice to use constants/variables like these 

            //in case you want to use them in more than just the ControlAvailable method 


            //this has to match the actual name of the grid control (by default it gets called "grid") 

            private const string ITEMS_CONTROL = "grid";


            //this is somewhere to store a reference to the grid control 

            private DataGrid _itemsControl = null;


            #region  Event Handlers

            private void DemoItemList_InitializeDataWorkspace(System.Collections.Generic.List<Microsoft.LightSwitch.IDataService> saveChangesTo)


                //here we're adding an event handler to get a reference to the grid control, when it becomes available 

                //and we have no way of knowing when that will be 

                this.FindControl(ITEMS_CONTROL).ControlAvailable += DemoItems_ControlAvailable;



            private void DemoItems_ControlAvailable(object send, ControlAvailableEventArgs e)


                //we know that the control is a grid, but we use TryCast, just in case 

                _itemsControl = e.Control as DataGrid;


                //if the cast failed, just leave, there's nothing more we can do here 

                if (_itemsControl == null)





                //set the property on the grid that allows multiple selection 

                _itemsControl.SelectionMode = DataGridSelectionMode.Extended;

                _itemsControl.SelectionChanged += new SelectionChangedEventHandler(ItemsControl_SelectionChanged);






    • Edited by reigh7 Saturday, September 28, 2013 8:30 PM
    Saturday, September 28, 2013 8:20 PM
  • "Elyl's extensions" is a broken link so I found it through a search engine. these are the Blog and Extensions links
    • Edited by reigh7 Saturday, September 28, 2013 8:40 PM
    Saturday, September 28, 2013 8:39 PM