Latest update creates bug

C:\Program Files\Radzen\resources\node_modules\@radzen\blazor-server\dist\templates\page.razor.cs.ejs:101
    99| <%_ allComponents.filter(c => env.canHaveRef(c)).forEach(component => { _%>
    100| 
 >> 101|         protected <%- env.renderRefType(component) %> <%= env.componentRefName(component.name) %>;
    102| <%_ }) _%>
    103| <%_ properties.filter(p => !(globalProperties || []).find(gp=> gp == p.split(':').shift())).forEach(name => { _%>
    104| 

Cannot read property 'charAt' of undefined

I have just updated radzen and now get the above error that was not ther before. How do i fix this?

Can you attach the page meta json declaration?

I searched for the string "allComponents.filter" from the error and, I guess that you are aware, this is in your Radzen code index.js. So it would appear that something in my code is tripping up your parser, what am I looking for?

The Radzen log seem to register the error twice for one event. This happens whe I click to open any page in the design tool.
[2020-09-11 08:52:09.327] [info] Checking license...
[2020-09-11 08:52:09.991] [info] License check result: false
[2020-09-11 08:52:48.445] [error] C:\Program Files\Radzen\resources\node_modules@radzen\blazor-server\dist\templates\page.razor.cs.ejs:101
99| <%_ allComponents.filter(c => env.canHaveRef(c)).forEach(component => { %>
100|
>> 101| protected <%- env.renderRefType(component) %> <%= env.componentRefName(component.name) %>;
102| <%
}) %>
103| <%
properties.filter(p => !(globalProperties || []).find(gp=> gp == p.split(':').shift())).forEach(name => { _%>
104|

			Cannot read property 'charAt' of undefined
			[2020-09-11 08:52:49.590] [error] C:\Program Files\Radzen\resources\node_modules\@radzen\blazor-server\dist\templates\page.razor.cs.ejs:101
				99| <%_ allComponents.filter(c => env.canHaveRef(c)).forEach(component => { _%>
				100| 
			 >> 101|         protected <%- env.renderRefType(component) %> <%= env.componentRefName(component.name) %>;
				102| <%_ }) _%>
				103| <%_ properties.filter(p => !(globalProperties || []).find(gp=> gp == p.split(':').shift())).forEach(name => { _%>
				104| 

			Cannot read property 'charAt' of undefined

OK. I have found the file causing the issue, it is my modified Main layout. This was not causing a problem before the upgrade however.

I renamed my json layouts uploaded previously - main.json --> mhmain.json and origmain.json --> main.json
Now the error does not appear when the pages use the original main template. The error does still appear for my modified template which has not been changed for a long time and has never been a problem before.

The error is being caused by a null style entry - "style": {},
I'm not sure how that got there or why it is suddenly an issue but removing this clears up the error :slight_smile:

.mhmain.zip (908 Bytes)

Actually the issue was caused by the following meta - which invalid:

    {
      "style": {}
    },
    {
      "style": {}
    }

I am now finding "style": {}, all over my files which is causing more problems. Where did it come from and why is it only a problem in the latest release?

It's not the empty style that is causing the problem but a component declaration with type.

Sorry, I don't understand. What am I doing to cause this?

I'm afraid that I'm not sure what can insert an empty component without type. Check your source control to see when these empty components where added.

But it even appears in my application-role.json whihc was autogenerated by Radzen at the start of the project...
"type": "row"
}
],
"container": "main",
"type": "content"
},
{
"style": {}
},
{
"style": {}
}
],
"events": {
"load": [
{
"name": "Security.getRoles",
image

I don't have such empty components in my just created app:
application-roles.zip (1.1 KB)

I agree, looking back in version control it was not there on first checkin. It seemed to happen to this file sometime between adding default authentication and adding page security - both done through the Radzen design tool.


We will release later today fix that will handle the code generation error in case of such empty components. If you can reproduce what’s causing the insertion of an empty component let us know.

Thanks. The empty component happened again whislt editing an existing page. I changed an image url from assets/images to /assets/images and this process seemed to trigger the empty component but I tried this again and tried on a new blank page and could not replicate the issue.
(the reason for having the url as relative path is for hosting in a subdirectory /mh/pages)

Hi,
I have run into a second problem that coincides with the update. I have a master/detail datagrid and now the class definition for all the datagridds in the templates do not get generated in designer.cs

The master grid gets defined and has a @ref in the html but the template child datagrids do not have @ref or a definition in designer.cs. This was working before the update.

protected RadzenGrid grid0;

  <div class="col-md-12">
<RadzenGrid @ref="grid0" AllowFiltering="true" AllowPaging="true" AllowSorting="true" ColumnWidth="150px" Data="@getitemitemsResult" TItem="My.Models.MyContext.itemitems" RowExpand="@Grid0RowExpand">
  <Columns>
  </Columns>
  <Template Context="MyModelsMyContextitemitems">
    <RadzenCard style="background-color: #faa728">
      <ChildContent>
        <RadzenCard>
          <ChildContent>
            <RadzenGrid AllowFiltering="true" AllowPaging="true" AllowSorting="true" ColumnWidth="150px" Data="@(MyModelsMyContextitemitems.Forms)" TItem="My.Models.MyContext.Form" RowSelect="@((args) =>Grid1RowSelect(args, MyModelsMyContextitemitems))">
              <Columns>
              </Columns>
            </RadzenGrid>
            <RadzenHeading Size="H1" Text="Mental Health Exams">
            </RadzenHeading>
            <RadzenGrid AllowFiltering="true" AllowPaging="true" AllowSorting="true" ColumnWidth="150px" Data="@(MyModelsMyContextitemitems.Exams)" TItem="My.Models.MyContext.Exam" RowSelect="@((args) =>Grid5RowSelect(args, MyModelsMyContextitemitems))">
              <Columns>
              </Columns>
            </RadzenGrid>

How do we revert to a previous version of Radzen? This has taken valuable time away from the project.

You can get any version from here:

Thanks. A bit more detail on the template datagrid, here is an extract from the json...

                  "allowFiltering": true,
              "allowPaging": true,
              "allowSorting": true,
              "columnWidth": "150px",
              "columns": 
			  ...                  
              "itemType": "My.Models.MyContext.ItemItems",
              "name": "grid0",
              "template": [
			  ...
			              "allowFiltering": true,
                          "allowPaging": true,
                          "allowSorting": true,
                          "attributes": [],
                          "columnWidth": "150px",
						  ...
						  "itemType": "My.Models.MyContext.Form",
                          "name": "grid1",
                          "type": "grid"
              ],
              "title": "",
              "type": "grid"

grid0 gets created correctly bit grid1 and other child grids do not.

I just tried the latest version of Radzen, it does not fix the second bug re master/detail datagrids. Sorry :thinking:

Yes, the build was already published. We will release fix tomorrow.

1 Like