WebHierarchicalDatagrid: Sys.ArgumentException: Cannot deserialize on Row Expand

I have been using WebHierarchicalDataGrid with manual load on demand bands with a pretty good success until I hit this snag.

The WHDG has correctly displayed HTML fields before, but this time a column with HTML data (an HREF link to be precise) is needed as one of the grid’s DataKeyFields to provide uniqueness of the row:

WHDG with HTML column

The problem with this setup is that first attempt to expand a parent row to display children resulted in displaying garbage text in the grid:

WHDG with garbage text

And attempt to expand another row would throw a JavaScript error:

Error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON. Parameter name: data

After some research the culprit was found. Looking at HTML HREF element in question:

<a style=”color:blue” href=”FI_DownLoadFileAttachment.aspx?file_id=222″>METRIC_GENERATOR_SETUP_SCRIPT.sql</a>

it contains colon “:” and double-quote ” – main punctuation signs of JSON structure. The solution: Replace them! Double quotes with single quotes, inline styles with CSS classes, e.g.

<a class=’cellLink’ href=’FI_DownLoadFileAttachment.aspx?file_id=222′>METRIC_GENERATOR_SETUP_SCRIPT.sql</a>

Replacement can be done any place convenient/available to you: backend DB or code. After that – row expanding works with no problems.

Leave a Reply

Your email address will not be published. Required fields are marked *