Whitespace in DataGrid Cell Template

I have a DataGrid and in one column, I have defined a custom template, which looks like this

Label 1: ${data.Company} Label 2: ${", " + data.Name}

The reason why I use two labels is that the first label is formatted in bold.

The desired output in the datagrid cell should be:

Some Company, Some Name

However, the actual output looks like this:

Some Company , Some Name

(note the extra space after the company name, before the colon!)

The reason for that is there is some whitespace and comment tags between the two label tags in the rendered HTML. Is there a way how to prevent this behaviour?

Thanks for your suggestions!

We will need more details - what is the actual value of your Template and the generated code?

The template code (from the json file) looks like this:

"template": [
                        {
                          "name": "label0",
                          "style": {
                            "fontWeight": "bold"
                          },
                          "text": "${data.Contact?.Company}",
                          "type": "label"
                        },
                        {
                          "name": "label2",
                          "text": "${\", \" + data.Contact?.Firstname}",
                          "type": "label"
                        },
                        {
                          "name": "label3",
                          "text": "${\" \" + data.Contact?.Lastname}",
                          "type": "label"
                        }
                      ],

In the rendered HTML code, it looks like this:

<span class="rz-cell-data" title=""><!--!-->
<!--!-->    <label style="font-weight: bold" class="rz-label" id="fXW8ehJPLE" _bl_b14ed650-36f4-473a-ab75-2b0b39641f77="">ACompany</label><!--!-->
<!--!-->
                <!--!-->    <label class="rz-label" id="f0GAAUCL8E" _bl_0298ddcd-8598-4e05-89d0-b26357a3eb67="">, AFirstname</label><!--!-->
<!--!-->
                <!--!-->    <label class="rz-label" id="90BR6uc0bE" _bl_d65daf08-feef-429e-9ff7-9d0233081df1=""> ALastname</label><!--!-->
</span>

You see there is a lot of whitespace/comments between the actual label tags which cause the extra space before the colon.

Any ideas how to fix this? Merging the labels into one single label is not an option because the company name (first label) is supposed to be formatted differently (bold in this case).

Thanks a lot!

Hi @JustJoe,

In my opinion the comma should be at the end of the first label to avoid such problems.

Hi @enchev ,

yes, I also thought of that but this would also make the colon bold. Is there no chance to prevent the whitespace/comments which are rendered automatically?

Thanks a lot!

These are rendered by the Blazor framework and are beyond our control.