Changing grid cell backcolor not working


(Pierre Hogue) #1

I only want to mimic the Dashboard conditionnal color setup…in my UD14 form.

I found the following code to change the BackColor of my cell but nothing is changed…

private void GrilleUD14_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
if((e.Row.Cells[“CheckBox01”].Value != null) && ((bool)e.Row.Cells[“CheckBox01”].Value))
{
e.Row.Cells[“Character01”].Band.Override.CellAppearance.BackColor = Color.Green;
e.Row.Cells[“Character01”].Band.Override.CellAppearance.BackColor2 = Color.Green;
}

}

The grid does have the “useAppStyling” set to true…'cause otherwise it is not looking that great… :wink: but even when it is off the color is not showing as if it gets revert back to original setting afterwards…

Any thoughts?

thanks

Pierre


(Pierre Hogue) #2

I did try The wizard to create a row rule…which I beleived was what I was looking for… but even that was not working…

I wander is there an order needed to setup the rowrule like for now it is before I read the UD14 data…(I did try after reading the data as well with no results…)

Another note:
I tested with a String field and got the coloring via RowRule.

Checking on the CheckBox01 I tried
Equals true
Equals 1

And it was not picked up I guess…
So what shoul;d be the valid way to add a condition on a boolean field ???

thanks

Pierre


(Jose C Gomez) #3

you can use true the word true in the RowRule works well… Row Rules are the way to go for this kind of thing.


(Brandon Anderson) #4

You can hijack the row rules to get more colors. Use the wizard to make the row rule, then change the code it give you. I’ve done it with the help of someone who posted it here, but now I can’t seem to find it… You end up getting errors when open the customization, but you can ignore them. Here’s a code snippet for what I used. There might be something else you have to do, but I can’t remember at the moment.

	private void CreateRowRuleV_PackOrNotUpdate2_1ViewUD08_ShortChar02Equals_P()
	{
		// Description: Pack
		// **** begin autogenerated code ****
		ControlSettings PackGreen = new ControlSettings();
		PackGreen.BackColor = System.Drawing.Color.LawnGreen;

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

edit: Here’s the original post:


(Daryl Hewison) #5

Maybe beyond what you need, but if you bypass the standard Epicor grid binding by leaving the EpiBinding field for it blank, then in the customization bind the grid in code to the DataTable that the EpiDataView is a view of, you can then do anything to that grid that Infragistics supports, including any colour you like under any conditions.


(Jose C Gomez) #6

This is generally not a good idea, you lose a ton of functionality with this and all the EpiMagic (Open With, Publish and Subscribe, Auto Save on record change… and much more)


(Brandon Anderson) #7


(Daryl Hewison) #8

Well yes, of course. But sometimes all that is surplus to requirements anyway and you do just need some basic functions that Epicor DOESN’T provide. It’s nice to know both ways exist.

You don’t lose “Open with”, incidentally.


(Pierre Hogue) #9

OK, back to my issue… I was able to make the row rules (I have three) to show the colors. But I noticed the following:
On the form load, the colors are assigned to the wrong rows, and as soon as click in one of the cells, all the colors are showing correctly to the right rows… like magic… :wink:

When is this coloring happen? Should I force it somehow on load, and if so what would be the code to use?

Also, I have implemented a filter based on one of the fields, having 5 options to filter. So the user can select one choice and the list of rows in the grid changes accordingly. this works.
But all the coloring does not occur, unless I click again in one of the cells.
Again here I guess I need to call some function to activate the coloring… ?

Any toughts ?

thanks

Pierre


(Brandon Anderson) #10

Are you doing a save after you change the value? The colors for mine won’t change until after a save. Clicking on a new row, or sometimes a different cell, generally triggers a save (in dashboards anyways). You could probably put in some form event triggers to initiate a save, but I would imagine you might take some unwanted performance hits.

I see this too, I just live with it. Once I click in there it all goes to what it should be. It would be nice if it didn’t do that, but I don’t know how to fix it.


(Pierre Hogue) #11

Actually yes I do a save on load because I am reading dynamic data from my BAQ into it.
I will then try to force a focus on the first cell … I wander if that might work… ?

will let you know

Pierre


(Pierre Hogue) #12

Whoa getting a tid bit frustrated here…

I wander if 10.2 has the same behavior…(we are on 10.0.700.2)

I click at first the colors are changed ok… I press on my filter and sometimes it works sometimes I need to click again on a cell.

Within each Filter change event I tried the following to “simulate” a click
GridUD14.Focus();
GridUD14.ActiveCell = GridUD14.Rows[0].Cells[“Character02”];

but no conclusive results. Still randomly works…annoying…

Pierre


(Brandon Anderson) #13

10.2 does it too. The dashboard that I have in both 10.1.500 live and 10.2.200 test have the same behavior.


(Mark Damen) #14

@Banderson I posted the code for you originally - I spoke with @Edge at Insights regards the length issue upon opening the customisation. Stephen suggested trying to trim out code until the error goes away which I’ve done, but even with no code in the row rule method it still errors - the custom code parser seems to be trying to do a Substring with an invalid length. Without decompiling to see what length it is passing in, I just live with the warning as it’s only in developer mode.

Regards the colouring of the rows - mine work upon load, without forcing an extra save or changing focus. This is relying upon the native functionality of the form (which in my case is actually a customisation layer on top of a dashboard assembly if that makes any difference…). I’m on 10.1.600.14 at present.