Hi,
I am using conditional formatting on some columns in my grid. One of the columns is a date/time column on which I have created a Formula condition such as this:
"datediff( "d" , [//FormulaCondition/ConditionValue] , today() ) > 30"
This condition checks if the date of the column is at least 30 days in the past.
I find when I apply such a condition, the grid performs very slowly in scrolling etc. Also when I save the grid layout with this condition, it changes the UI render time from about 0.4 to 4 seconds.
I have experimented with other date/time functions (such as check if the cell value is equal to a particular date) and get similar poor performance.
Anyone experience this before? is this a bug?
Thanks!
David.
I was playing around with a sample program and I think I have found the cause of my slowdown. Many of my rows have a null value in the date/time column. Once I inserted a "isdbnull()" condition before the datediff condition and turned off "apply all matching conditions" option, the slowdown was completely fixed.
I guess the date/time formulas have trouble dealing with null values.
is this still a bug? At least there is a workaround for now.
Try setting the Visual Studio IDE to break on all run-time exceptions and then run it and see if any exceptions are occurring. If there are exceptions, then that would explain the slowdown. Exceptions tend to slow things down quite a bit, even when they are handled internally. If that's the case, then I would say that this probably is a bug. The CalcManager should be checking for nulls or DBNulls explicitly rather than raising and catching exceptions.
Hi Mike
I tried as you suggested and no exceptions seemed to be thrown (I verified by throwing my own exception which did break execution).
In that case, I'm not sure why it would be slowing down. It's probably a good idea for your code to check for null, anyway.
If you can create a small sample project demonstrating the issue, I'd be happy to check it out.
I have attached a sample app - if you right click on the date/time column you can apply conditional formatting
Then scroll down to the rows with a null value in that column and you will see the slowdown while scrolling past those rows. There is also a slowdown when you load a layout containing such a conditional format (although this is not included in the sample).
Thanks
Hi David,
I tested this out and I see the problem. Oddly enough, when I turned on Exception handling, I got an exception. Basically the CalcManager is trying to convert DBNull into a DateTime using the IConvertible interface.
Now, the CalcManager could check for DBNull before attempting the IConvertible conversion. In some cases, that would not be a prudent thing to do, because it's not a good idea to make assumptions about the IConvertible Implementation - since it could theoretically change. But in this case, it's pretty safe for us to do and it would eliminate the slowdown you are getting here.
I'm going to froward your post over to our Developer Support team and ask them to write this up as a bug so we can correct it.
Thanks Mike for all the help