I am working on bringing applications with older components to the 2020.1 fold .. I have the following problem that I need to resolve.
On one hierarchical grid there is a need to format cells as the underlying data is floating point but only one row actually need to show decimals while the rest of the data should be whole numbers…. In an old application that was addressed by assigning delegate to the GridView.Columns[i].FormatFieldMethod that actually return the correct formatting string. It worked fine.. In new components it blows up if data on the grid was updated… If you can have a look and advise how to address the issue.
Here steps to recreate :
2. Click Post button, page get reposted, all the same.
3. Change some value in the a5 or a6 column on the main grid. It blows up, as somehow the lr4whdg reference is not there .. it also skips lr4whdg_RowUpdating event.. It does not skip it and works fine if data on the child grid updated..
WHG.zip
Hello Michael,
After investigating this further, I determined that the behavior is observed because the currentRow variable gets higher than the number of rows in the grid. What I could suggest is checking whether the row with index currentRow is not null in the FormatTotalField method as follows:
protected string FormatTotalField(ControlDataField field, object val)
{
if (this.lr4whdg.Rows[currentRow]!= null && (string)this.lr4whdg.Rows[currentRow].Items[1].Value == "TAXRATE")
. . .
}
Additionally the “RowUpdatingEvent” is fired when the Post_Back takes place, which is the default behavior when BatchUpdating is enabled.
Please let me know if you need any further information regarding this matter.
Regards,
Monika Kirkova,
Infragistics
Hi Monika, unfortunately thing a bit more complicated. To be fair I tried to use yours if statement and it did not work the same way with the same error.. that was expected as lr4whdg somehow does not exist at that moment...
Here couple of more consideration to check.. In old components ( 2013.2) that I am trying to leave as they not supported the following sequence of events take place:
Page_Load, Page_LoadComplete, Page_PreRender and then FormatTotalField is called for every row & column
This sequence repeated on every post back unless some data was updated .. if it was then the following happening :
Page_Load, lr4whdg_RowUpdating Page_LoadComplete, Page_PreRender and then FormatTotalField is called for every row & column .. In that version (2013.2) at this point when FormatTotalField the lr4whdg having reference to the grid object and everything works smoothly.
In new, supported components (2020.1) the sequence after update is broken : FormatTotalField starts getting calls right after Page_Load and at this point throwing exception on the first call (see image below) .. While it is probably does not matter , if data changed in the child grid.. it works ok, probably because it does not need formatting..
Please try to run the poc project that I uploaded and help me to find solution.. if you would see any other way to dynamically format cells , that is fine..but I would prefer to find fix for the existing approach.
I need it to apply formatting just for some limited number of cells in one row..
Thanks.