Base solution for your next web application
Open Closed

Client Template - Unable to read object property. #11908


User avatar
0
Astech created

I'm trying to access a string from this object property:

"#if(" + (IsGranted("#=EntitySearch.ViewPermissionName#")).ToString().ToLower() + "){#" +

But I'm getting the following error as it's trying to search for the literal string instead of the property.

Abp.AbpException: There is no permission with name: #=EntitySearch.ViewPermissionName#

This works fine so I'm wondering if it's the IsGranted wrapper breaking it?

"#=EditModalButtonTemplate('EntitySearch.EditModalFunctionName', EntitySearch.Id)#"

The full grid:

                    @(Html.Kendo().Grid<SearchViewModel>().Name("EntitySearchList")
                        .DataSource(dataSource => dataSource
                            .Custom()
                            .Transport(transport =>  { transport.Read(read => read.Url(@Url.Action("Search_Read", "Searches")).DataType("json").Data("additionalData")); })
                            .Schema(schema => { schema.Model(m => m.Id("EntitySearchModel.Id")); schema.Data("Result.Result.Data").Total("Result.Result.Total"); })
                        )
                        .Columns(columns =>
                        {
                            columns.Bound(p => p.EntitySearch.Id).Title(" ").Filterable(false).Sortable(false).IncludeInMenu(false).HtmlAttributes(new { @class = "actions-column-cell" }).ClientTemplate(

                            "#if(" + (IsGranted("#=EntitySearch.ViewPermissionName#")).ToString().ToLower() + "){#" +

                            "#=ViewLinkButtonTemplate('" + @Url.Action("EntitySearch.ControllerViewFunctionName", "EntitySearch.ControllerName") + "', EntitySearch.Id" + ")#" +

                            "#}" +

                            "#=EditModalButtonTemplate('EntitySearch.EditModalFunctionName', EntitySearch.Id)#" +

                            "#=HistoryModalButtonTemplate(EntitySearch.Id, EntitySearch.Name, '" + @EntityTypeFullNames.Team.ToString() + "')#");

                            columns.Bound(p => p.EntitySearch.Id).IncludeInMenu(false);
                            columns.Bound(p => p.EntitySearch.SearchTypeDisplayName).IncludeInMenu(false);
                            columns.Bound(p => p.EntitySearch.Name).IncludeInMenu(false);
                        })
                        .Pageable()
                        .Events(events => events.DataBound("onDataBound"))
                        .NoRecords(x => x.Template("<div class='empty-grid'>" + string.Format(@L("NoSomethingFound"),@L("CompletedActions").ToLower()) + "</div>"))

                    )

3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think you can directly use an if statement instead of combaning strings.

  • User Avatar
    0
    Astech created

    Hi,

    I think you can directly use an if statement instead of combaning strings.

    Could you give an example?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Astech

    Is it possible to share your project with us ? If so, please send an email to [email protected] and we will do it on your project.