Custom Background Colours (Colors) for EpiUltraGrid Style using RowAction and RowRule

This took me far too long to work out, so figure it could be helpful to others.
Basically, I wanted to highlight rows in an EpiUltraGrid with a colour that isn’t red, Green, Yellow or Grey. To do this, you need to create a ControlSetting and pass that to the last parameter of RowAction.

Example:

// Set the conditional Row formatting
// Create the Style
ControlSettings StyleBrown = new ControlSettings();
StyleBrown.BackColor = System.Drawing.Color.FromArgb(220,190,150);
// Setup the Actions (styles) to apply
RuleAction RowActionStyleBrown = RuleAction.AddRowSettings(this.oTrans, “AssignedAllergens”, true,StyleBrown);
RuleAction[] RuleActionsBrown = new RuleAction[] {RowActionStyleBrown };
// Create RowRule and add to the EpiDataView.
RowRule NewRowRuleBrown = new RowRule(“AssignedAllergens.AttrCode”, RuleCondition.Equals, “ORGANIC”, RuleActionsBrown);
((EpiDataView)(this.oTrans.EpiDataViews[“AssignedAllergens”])).AddRowRule(NewRowRuleBrown);

I used this method, I’m not at a computer right now to really check out the differences. Do you still get the goofy warning messages when you open up the customization?

I didn’t see that one. It seems to be the same as what I’m doing and I haven’t seen the goofy warning.

Yeah, that would be hard to find if you didn’t know it was there. Maybe they fixed the message . It was something like key not found or something. I’ll have to check it on Monday.

Confirm the annoying error on opening the customization still exists in 10.1.600.28 - not sure on 10.2.

I have to click through 10 of the same errors when opening my Job Reporting Dashboard customization!

I see it in 10.2.200.13

many thanks @AndrewM, any idea how i can add these code lines, so that new option will appear on dashboard view rules, or you suggest to do it differently?

It’s bypassing those settings, so it has to be done in code. That would be nice feature though.

so the code will do what this dashboard feature doing, so my question then do i need to hard-code my value within the class call?

@josecgomez posted a really good example of how to make it work here. I think this will answer your question.

And I notice that you have a run-time dashboard, you would need to deploy an assembly and make a customization to make this work.

What’s the goofy warning that people are seeing? We’re on 10.2.200.11 and haven’t seen anything odd. Could the difference be that I made the change to a custom control?

When I open the customization (not the customized form, the actual customization editor) this pops up. One for every row rule that I modified. So I have 6 pop up for me. Otherwise it works just fine.

image

Here’s the code for mine, as far as I can tell, it’s the same exact as yours except for my names are a lot longer because I ended was modifying the wizard generated code. Maybe that’s what the problem is? If I didn’t use the wizard, maybe this error wouldn’t show up?

	private void CreateRowRuleV_PackOrNotUpdate2_1ViewUD08_ShortChar02Equals_CA()
	{
		// Description: CustomerAssy
		// **** begin autogenerated code ****

		ControlSettings CustomerAssyBrown = new ControlSettings();
		CustomerAssyBrown.BackColor = System.Drawing.Color.Chocolate;

		RuleAction errorV_PackOrNotUpdate2_1View_RowAction = RuleAction.AddRowSettings(this.oTrans, "V_PackOrNotUpdateable_1View", true, CustomerAssyBrown);
		RuleAction[] ruleActions = new RuleAction[] {errorV_PackOrNotUpdate2_1View_RowAction};
		// Create RowRule and add to the EpiDataView.
		RowRule rrCreateRowRuleV_PackOrNotUpdate2_1ViewUD08_ShortChar02Equals_CA = new RowRule("V_PackOrNotUpdateable_1View.UD08_ShortChar02", RuleCondition.Equals, "CA", ruleActions);
		((EpiDataView)(this.oTrans.EpiDataViews["V_PackOrNotUpdateable_1View"])).AddRowRule(rrCreateRowRuleV_PackOrNotUpdate2_1ViewUD08_ShortChar02Equals_CA);
		// **** end autogenerated code ****
	}

That looks mighty similar to me. Have you tried selecting ‘All Code (Read Only)’ in the script editor in case some automatically added code is messed up? That being said, it seems more like an editor bug than the custom code.
If you just remove the code for the conditional formatting, does the error go away?

One other thought… I have the code in my method to initialize the adapter which does an initialize then refresh of data before adding the row action, just after a refresh data like this:

		// Create the adapter and connect it to the database
		this._abaUnassignedAllergens = new AttrBinAdapter(this.oTrans);
		this._abaUnassignedAllergens.BOConnect();

		// Add Adapter Table to List of Views
		// This allows you to bind controls to the custom UD Table
		this._edvUnassignedAllergens = new EpiDataView();
		this._edvUnassignedAllergens.dataView = new DataView(this._abaUnassignedAllergens.AttrBinData.AttrBin);
		this._edvUnassignedAllergens.AddEnabled = false;
		this._edvUnassignedAllergens.AddText = "Remove Allergen";


		if ((this.oTrans.EpiDataViews.ContainsKey("UnassignedAllergens") == false))
		{
			this.oTrans.Add("UnassignedAllergens", this._edvUnassignedAllergens);
		}

		refreshUnassignedAllergensGridData();

		// Set the conditional Row formatting
		ControlSettings StyleGreen =  new ControlSettings();
		StyleGreen.BackColor = System.Drawing.Color.FromArgb(100,200,100); 
		// Setup the Actions (styles) to apply
		RuleAction RowActionStyleGreen = RuleAction.AddRowSettings(this.oTrans, "UnassignedAllergens", true, StyleGreen);
		RuleAction[] NewRuleActionsGreen = new RuleAction[] {
				RowActionStyleGreen };
		// Create RowRule and add to the EpiDataView.
		RowRule NewRowRuleGreen = new RowRule("UnassignedAllergens.AttrCode", RuleCondition.Equals, "A-FREE", NewRuleActionsGreen);
		((EpiDataView)(this.oTrans.EpiDataViews["UnassignedAllergens"])).AddRowRule(NewRowRuleGreen);

A little, but I can’t change it so I didn’t dig in that hard.

I’m not using an adapter because the grid is populated with a grid already native to the dashboard. It could be the difference??

Could be. My thinking was that the data view hasn’t been initialized when the custom code is being called. The other thing is that I created my by first adding the standard row rule (just select Error) and then modified that. It could be a hidden table parameter that is being changed. Have you checked what happens if you just add a standard row rule to see if you still get the error?

I’m sure that @josecgomez would know. He’ll probably read this thread at some point and laugh at us.

The weird things is, the error only comes up when opening the customization editor. In normal use it works fine. That’s why I haven’t dug into it too hard. It pretty much just annoying to me , since I’m the only one that sees the errors.

And yes. Standard row rules work just fine.

Yeah… I’m just too curious when things like this happen.
There have been a few bugs in the customization editor that I’ve run into in the past (one which would somehow copy all the uneditable code to standard code if you saved while showing all code), but they seem to be fixed in our current version, so wouldn’t surprise me if there is an editor bug.
I’ll probably review it if I see the error.

I showed @Rich this problem at Insights earlier in the year. Rich, I can’t remember your answer but it was something to do with a bug in the editor?

@Banderson , Did you ever resolve this little bug? Has it cause issues during an Epicor upgrade? This code snipit is perfect for getting access to over 100 different colors, but others in my organization are nervous about this causing an issue during an Epicor Update.

I haven’t seen any issues with things getting messed up in upgrades. In reality, you’ve maybe got one more upgrade left until this will all be obsolete anyways.