Radio buttons in a grid?


(Brandon Anderson) #1

It it possible to put radio buttons within a grid on a dashboard? I have five conditions, and only one of them can be true and any given time. I’m guessing that I could make check boxes work with some code in a customization, but since radio buttons are designed for that, and I could manage with just one field, it would be a lot cleaner. However, my application requires reviewing a lot of lines of data so a detail type screen will not work very well to go through everything fast enough.

Thoughts?


(Jose C Gomez) #2

Try a dropdown instead that should give you the same conditions as a radio button since only one value can be selected at a time.


(Brandon Anderson) #3

I thought of that, and technically, it would work. Unfortunately it’s too slow. I’m working on a solution to try and go through prints to show what needs to be assembled and what needs to be packed separate. (we have large jobs that leave on many trucks with final assembly done on the job site be the customer). So the shop super or assembly lead will have to review each assembly sequence that has an assembly operation and assign a status to each asm/mat sequences on whether the part gets assembled, partially assembled (pack some but not all), pack all, or not finished here (assembled by customer). This information can then feed into our packing list creator system for verification on what needs to ship so that they know they got it all. Right now that system just allows them to put stuff on a list, but doesn’t tell them what needs to be on the list.

If I can find out how to get it to work, I think I can get a good visual of the assemblies child parts in a grid with radio buttons or check boxes. Plus, they can be clicked through quickly. A drop down makes that harder to see and harder to change. Probably hard/slow enough that they won’t use it. Then I end up back where I am now.

It’s a good suggestion, I just need something that scales up a bit easier.

edit: this sure seems like a perfect application for designing a custom application that uses rest huh? Man I wish I new how to code…


(Brandon Anderson) #4

The option set is something that looks like it’s available in the infragistics tools set. Can this be made to work with E-10?

https://www.infragistics.com/products/windows-forms/grids-and-lists/grid


(Jose C Gomez) #5

Yeah you should be able to use that, it would require to custom code it, but yes.,


(Brandon Anderson) #6

in your opinion, would it be easier to code check boxes to act like radio buttons (I have dabbled a little bit with that type of thing, basically set values on row change) or use this option set tool?


(Chris Conn) #7

No experience personally but according to Infragistics:

Putting radio buttons in a cell is very easy. What you do is place an UltraOptionSet control the form with your grid. Populate the OptionSet with the items you want (Yes / No / Not Sure). Then you set the column’s EditorComponent property to the UltraOptionSet control.

When the user selects an option, the cells value will be set to the Value of the selected item in the OptionSet.


(Brandon Anderson) #8

So I think I have exceeded my ignorance level on this.

I managed to get myself in to see the code for this example and and trying to apply it to epicor.

https://www.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/72048/ultra-grid-with-radio-buttons

Here is the code I am using for an example.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Infragistics.Win.UltraWinEditors;

namespace UltraGridWithRadioButtons96866
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

this.Load += new EventHandler(Form1_Load);
}

void Form1_Load(object sender, EventArgs e)
{
ultraGrid1.DataSource = GetData();
ultraGrid1.DataBind();

//Create a new instance of the UltraOptionSet
UltraOptionSet ultraOptionSet1 = new UltraOptionSet();

//Create the necessary ValueListItems to represent each of the desired options
Infragistics.Win.ValueListItem valueListItem1 = new Infragistics.Win.ValueListItem();
Infragistics.Win.ValueListItem valueListItem2 = new Infragistics.Win.ValueListItem();
Infragistics.Win.ValueListItem valueListItem3 = new Infragistics.Win.ValueListItem();

//Assign a data value for each option
valueListItem1.DataValue = "Yes";
valueListItem2.DataValue = "No";
valueListItem3.DataValue = "Not Sure";

//Assign the text which will be displayed within the UltraGrid for each option
valueListItem1.DisplayText = "Yes";
valueListItem2.DisplayText = "No";
valueListItem3.DisplayText = "Not Sure";

//Add each ValueListItem object to the items collection of the ultraOptionSet
ultraOptionSet1.Items.AddRange(new Infragistics.Win.ValueListItem[] {valueListItem1, valueListItem2, valueListItem3});

//Set the UltraOptionSet instance as the EditorComponent for the first column of the UltraGrid
ultraGrid1.DisplayLayout.Bands[0].Columns[0].EditorComponent = ultraOptionSet1;

//Resize the column to fit the presented options
ultraGrid1.DisplayLayout.PerformAutoResizeColumns(false, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.VisibleRows);
}

//Create some sample data for the UltraGrid
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add();
for (int i = 0; i < 9; i++)
{
    dt.Rows.Add("item" + i.ToString());    
}
return dt;
}
}
}

And this is what I managed to hobble together.

// **************************************************
// Custom code for UD08Form
// Created: 2/21/2018 10:56:33 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

EpiUltraGrid MainGrid;
UltraOptionSet PackOption;
ValueListItem Pack;
ValueListItem Assemble;
ValueListItem None;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
		MainGrid = (EpiUltraGrid)csm.GetNativeControlReference("7908565c-cc3c-43d1-b85b-9921ad88fb89");

	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
		MainGrid = (EpiUltraGrid)csm.GetNativeControlReference("7908565c-cc3c-43d1-b85b-9921ad88fb89");
	}

	private void UD08Form_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code


		// adding the option set, and the value list variables
		UltraOptionSet PackOption = new UltraOptionSet();
		ValueListItem Pack = new Infragistics.Win.ValueListItem();
		ValueListItem Assemble = new Infragistics.Win.ValueListItem();
		
		//assign the value for each option
		Pack.DataValue = "P";
		Assemble.DataValue = "A";
		None.DataValue = "";

		//Assign the text which will be displayed within the ultragrid for each option
		Pack.DisplayText = "Pack";
		Assemble.DisplayText = "Assy";
		None.DisplayText = "None";

		//add each ValueListItem object to the items collection fo the UltraOptionSet
		PackOption.Items.AddRange(new Infragistics.Win.ValueListItem[] {Pack, Assemble, None});

		//Set the UltraOptionSet instance as the EditorComponent for the Column of the UltraGrid
		MainGrid.DisplayLayout.Bands[0].Columns[8].EditorComponent = MainGrid;

		// Resize the column to fit the presented options
		MainGrid.DisplayLayout.PerformAutoResizeColumns(false, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.VisibleRows);

	}
}

It compiles ok, but when I try to load it after saving, I get this error.

Application Error

Exception caught in: mscorlib

Error Detail 
============
Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Object reference not set to an instance of an object.
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

Client Stack Trace 
==================
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeScriptMethod(MethodInfo scriptMethod, Object[] parameters)
   at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeCustomFormLoadIfExists(String methodName, Object sender, EventArgs e)
   at Ice.Lib.Customization.CustomScriptManager.<>c__DisplayClass103_0.<OnCustomCodeFormLoad>b__0()
   at Ice.Lib.Customization.CustomScriptManager.TryActionShowExceptionBoxOrLogVerificationErrorIfException(Action action, String exceptionBoxTitle)

Inner Exception 
===============
Object reference not set to an instance of an object.



   at Script.UD08Form_Load(Object sender, EventArgs args)

So now I am stuck. Some things that I am pretty sure that I am doing wrong.

  1. I don’t know how I am supposed to bind my field (PackStatus_c) to the OptionSet. The example isn’t using a data source so I can’t copy what they have. I think there has to be something that binds the column and the field correct?

  2. I’m assuming that the form load has to have something else after it right?. The sample has GetData(); but that doesn’t seem to work in this case.

So again, I apologize for my ignorance, you can laugh if you want, it probably won’t hurt my feelings. Unfortunately I think I’ve gone as far as I can get google to take me.


(Brandon Anderson) #9

Ok, I found the errors in my code that caused the error. This is my code now.

// **************************************************
// Custom code for UD08Form
// Created: 2/21/2018 10:56:33 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win.UltraWinEditors;
using Infragistics.Win;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

EpiUltraGrid MainGrid;
UltraOptionSet PackOption;
ValueListItem Pack;
ValueListItem Assemble;
ValueListItem None;

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
		MainGrid = (EpiUltraGrid)csm.GetNativeControlReference("7908565c-cc3c-43d1-b85b-9921ad88fb89");

	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
		MainGrid = (EpiUltraGrid)csm.GetNativeControlReference("7908565c-cc3c-43d1-b85b-9921ad88fb89");
	}

	private void UD08Form_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code


		// adding the option set, and the value list variables
		UltraOptionSet PackOption = new UltraOptionSet();
		ValueListItem Pack = new Infragistics.Win.ValueListItem();
		ValueListItem Assemble = new Infragistics.Win.ValueListItem();
		ValueListItem None = new Infragistics.Win.ValueListItem();
		
		//assign the value for each option
		Pack.DataValue = "P";
		Assemble.DataValue = "A";
		None.DataValue = "";

		//Assign the text which will be displayed within the ultragrid for each option
		Pack.DisplayText = "Pack";
		Assemble.DisplayText = "Assy";
		None.DisplayText = "None";

		//add each ValueListItem object to the items collection fo the UltraOptionSet
		PackOption.Items.AddRange(new Infragistics.Win.ValueListItem[] {Pack, Assemble, None});

		//Set the UltraOptionSet instance as the EditorComponent for the Column of the UltraGrid
		MainGrid.DisplayLayout.Bands[0].Columns[8].EditorComponent = PackOption;

		// Resize the column to fit the presented options
		MainGrid.DisplayLayout.PerformAutoResizeColumns(false, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.VisibleRows);

	}
}

So the form opens with no errors, however the option set/radio buttons are not there. But it did do the resize columns, so something is working.

Update:
I changed the column number to 0 and now they show up under the company, so I think I just need to figure out the column number for my UD field and give that a shot.

Update 2:
So it doesn’t seem to like the extended UD fields. It works with the Character01, so I will probably just use one of those instead of making a field with a name that means something.


(Chris Conn) #10

I think you can use Column[“ColumnName”] as well


(Brandon Anderson) #11

So I did try that, but as soon as I saw your post realized that I forgot the “”. I’ll give that a shot and see if I can get the buttons to show up where I want.


(Brandon Anderson) #12

So now I have radio buttons, in a grid, in a dashboard. This is a rough prototype.

Next question is about styling. I can’t find anything about styling the radio buttons, but I figured I could use row rules. This seems to work ok, however, once I get the final version, there will be more options, and I fear that I will run out of styles.

Here is the autogenerated code for the row rule. Is there a way to just change the color instead of the whole style? Or can I make my own styles and set the color there?

	private void CreateRowRuleV_PackOrNotUpdate_1ViewUD08_PackStatus_cEquals_A()
	{
		// Description: AssembleRadioButton
		// **** begin autogenerated code ****
		RuleAction errorV_PackOrNotUpdate_1View_RowAction = RuleAction.AddRowSettings(this.oTrans, "V_PackOrNotUpdate_1View", false, SettingStyle.Error);
		RuleAction[] ruleActions = new RuleAction[] {
				errorV_PackOrNotUpdate_1View_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleV_PackOrNotUpdate_1ViewUD08_PackStatus_cEquals_A = new RowRule("V_PackOrNotUpdate_1View.UD08_PackStatus_c", RuleCondition.Equals, "A", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["V_PackOrNotUpdate_1View"])).AddRowRule(rrCreateRowRuleV_PackOrNotUpdate_1ViewUD08_PackStatus_cEquals_A);
		// **** end autogenerated code ****
	}

(Brandon Anderson) #13

Here’s an interesting tidbit in case anyone cares. If you use the advanced colmn editor configuration in the Ubaq, you can set a radio button configuration in the Ubaq.

Then you can add your options in the BAQ

Then when you put it in a dashboard, it automagically makes it a drop down for you.

I’m still going to change mine to radio buttons, (I guess it would be nice if this carried over into the dashboard as radio buttons…) but this could still be helpful for something else down the road…