Hi all. I'm using the latest UltrawebGrid 9.1 with browser=XML and LoadOnDemand set to XML as I want to minimize full postbacks as much as possible.
I need to be able to alter the background colour of the current row when certain columns contain certain values. I am putting code into the server side of UltraWebGrid1.UpdateRow
e.Row.Style.BackColor = Color.PaleGoldenrod
but this has no affect. I've also tried the same thing in the UpdateCell event (both of which are firing) - and still no luck.
Is there a way to achieve this?
Thanks in advance.
Jonathan
me again - in putting together a sample project I think I've found why it isn't changing the row style as I change a cell. I have a grid with 6 rows, and this is the debug trace as I change 1 cell...
UltraWebGrid1_Init UltraWebGrid1_InitializeDataSource UltraWebGrid1_InitializeRow UltraWebGrid1_InitializeRow UltraWebGrid1_InitializeRow UltraWebGrid1_InitializeRow UltraWebGrid1_InitializeRow UltraWebGrid1_InitializeRow UltraWebGrid1_UpdateCell new value is [x] UltraWebGrid1_UpdateRow
So you can see it does the InitializeDataSource and the process all 6 rows in InitialiseRow *before* it processes the UpdateCell.
I think I'm going to have to add some code into the AfterCellUpdateHandler client side event.
I have been able to change a cell's background colour client side - but I don't know how to set an entire row's background colour by changing the CssClass used for that row (I'd prefer to keep the colours in the css file rather than hard code into the javascript!)
Any suggestions on how to do that...or should I start another post?
Thanks again,
OK Vince, I will try and create a stand alone project and submit that as a support request, although as my 1st support request (CAS-28660-I530PV) which was logged on Monday is still 'awaiting assignment' I must say that I'm not overly impressed with the speed of response when using the 'paid for' support compared to how quickly you respond on these forums!
Anyway - I'll give it a go and keep my fingers crossed someone decides to help me in support ;)
Jonathan,
That behavior sounds strange. There may be something else going on for which I'm not accounting. It will likely take some more detailed research to determine what's happening.
Can you reproduce this behavior in a sample project that we can run and debug? If so, then I recommend you submit a support request and attach your sample. A Developer Support Engineer will research your issue using the sample provided and will work with you to get the behavior you're after.
Hi Vince, thanks for the quick reply...that solution sounded good...but I'm afraid I can't get it to work in practise.
I have defined a few cssClasses in my Stylesheet.css and in the InitialiseRow even (server side) I choose which cssclass to use as per your suggestion. This sets the background colour fo the rows that are loaded 1st time round - but it doesn't have any affect during an XML postback.
Any other ideas? Do I need to somehow handle the initialise row on the client side?
Use CSS to style your grid instead in this scenario.
The reason this occurs is because, when you set most Style properties on most Infragistics ASP.NET controls, the control will render inline CSS to the HEAD section of the page to represent the style change. When using an AJAX callback (whether through WebGrid's built-in AJAX, our WebAsyncRefreshPanel, or Microsoft's UpdatePanel), this inline CSS can't be included.
By having a CSS class defined and already available on the client, you can change styles on the server and expect them to reflect on the client. For instance, you'd have a CSS style defined with a "background-color" entry that matches the Pale Goldenrod color, then set the e.Row.Style.CssClass property equal to the name of that CSS class.