Telerik Forums
UI for ASP.NET MVC Forum
1 answer
17 views

Hello,

I'm fairly new to Kendo and having an issue when attempting to pass a CustomerID to a TabStrip from a Grid.

Based on the following article I have tried to follow to get Order data loaded on the TabStrip however I'm running into the below JavaScript error

https://demos.telerik.com/aspnet-core/grid/detailtemplate

Syntax error, unrecognized expression: #tabStrip_#=CustomerID# & Uncaught Error: Syntax error, unrecognized expression: #grid_#=CustomerID#

Please see Grid and TabStrip code below.

@(Html.Kendo().Grid<LewisTestProject.Models.Customer>()
  .Name("grid")
  .DataSource(dataSource => dataSource
      .Ajax()
      .Model(model => {
          model.Id(p => p.CustomerID);
          model.Field(p => p.CustomerID).Editable(false);
      })
      .PageSize(18)
      .Read(read => read.Action("Customers_Read", "Customer"))
      .Create(create => create.Action("Customers_Create", "Customer"))
      .Update(update => update.Action("Customers_Update", "Customer"))
      .Destroy(destroy => destroy.Action("Customers_Destroy", "Customer"))

   )
  .Columns(columns =>
  {
      columns.Bound(order => order.CustomerID);
      columns.Bound(order => order.CompanyName);
      columns.Bound(order => order.ContactName);
      columns.Bound(order => order.ContactTitle);
      columns.Bound(order => order.Address);
      columns.Bound(order => order.City);
      columns.Bound(order => order.Region);
      columns.Bound(order => order.PostalCode);
      columns.Bound(order => order.Country);
      columns.Bound(order => order.Phone);
      columns.Bound(order => order.Fax);
      columns.Command(command =>
      {
          command.Edit();
          command.Destroy();
      }
      ).Title("Actions");
  })
  .ToolBar(toolbar => {
      toolbar.Create();
      toolbar.Search();
  })
  .Pageable()
  .Sortable()
  .ClientDetailTemplateId("template")
  .Events(events => events.DataBound("dataBound"))
  .Editable(e => e.Mode(GridEditMode.InLine))
 )
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().TabStrip()
    .Name("tabStrip_#=CustomerID#")
    .SelectedIndex(0)
    .Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
    .Items(items =>
    {
        items.Add().Text("Orders").Content(@<text>
            @(Html.Kendo().Grid<LewisTestProject.Models.OrderViewModel>()
                .Name("grid_#=CustomerID#") // template expression, to be evaluated in the master context
                .Columns(columns =>
                {
                    columns.Bound(o => o.CustomerID);
                    columns.Bound(o => o.OrderID).Title("ID").Width(100);
                })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(5)
                    .Read(read => read.Action("OrdersDetail_Read", "Customers", new { customerID = "#=CustomerID#" }))
                )
                .Pageable()
                .Sortable()
                .ToClientTemplate()
                )
        </text>
        );
        //items.Add().Text("Contact Information").Content(
        //    "<div class='employee-details'>" +
        //        "<ul>" +
        //            "<li><label>Country:</label>#= Country #</li>" +
        //            "<li><label>City:</label>#= City #</li>" +
        //            "<li><label>Address:</label>#= Address #</li>" +
        //            "<li><label>Home Phone:</label>#= Phone #</li>" +
        //        "</ul>" +
        //    "</div>"
        //);
    })
    .ToClientTemplate()
    )
</script>

Any help would be greatly appreciated.

Thanks,

Lewis.

Anton Mironov
Telerik team
 answered on 28 Apr 2025
1 answer
20 views

Hi,

I have a kendo grid, where i am creating a new empty row while loading the grid.

The grid has a Boolean filed which is a mandatory field. so when we want to enter the row values then it should call the CheckIsPublicFund(data) method and if the user is not selecting the Boolean field then it should add that value to false.

The problem is when selecting the Boolean value then its not firing the CheckIsPublicFund(data)  method.

Attached below code and screenshot for reference.


columns.Bound(p => p.PublicFunds).Editable("EditFieldsForNewRec").ClientTemplate("#=CheckIsPublicFund(data)#").Title("Public Funds").Width(90).Filterable(ftb => ftb.Multi(true).Search(true)).HeaderHtmlAttributes(new {style = "justify-content:center"}).HtmlAttributes( new { style = "text-align:center"});
columns.Bound(p => p.CohortFtpRateFloor).Editable("EditFieldsForNewRec").Title("Cohort Ftp Rate Floor").Width(90).Filterable(ftb => ftb.Multi(true).Search(true)).HeaderHtmlAttributes(new {style = "justify-content:center"}).HtmlAttributes( new { style = "text-align:center"});
columns.Bound(p => p.HasDepositRateFloor).ClientTemplate("#=CheckIsDepositRateFloor(data)#").Editable("EditFieldsForNewRec").Title("Has Deposit Rate Floor").Width(90).Filterable(ftb => ftb.Multi(true).Search(true)).HeaderHtmlAttributes(new {style = "justify-content:center"}).HtmlAttributes( new { style = "text-align:center"});


function CheckIsPublicFund(data) {
    return data.PublicFunds ? "Yes" : "No"
}

function CheckIsDepositRateFloor(data) {
    return data.HasDepositRateFloor ? "Yes" : "No"
}

Eyup
Telerik team
 answered on 21 Apr 2025
1 answer
27 views

Hi,

I want to load a kendo grid, after load the grid should add a new row at the bottom of the grid. I want as per below screenshot.

 

This is the below method i am using to create a new row.

function AddNewRow() {
    var newRow = { field: "TlpModifierNew",  Value: 0 };
    var gridName = nmdModelGridTabNames[activeNmdModel3TabId - 1];
    var grid = $("#" + gridName).data("kendoGrid");
    grid.dataSource.add(newRow);
    var theCell = $('#' + gridName + " " +'tbody'+ " " +'tr:last-child td:eq(1)');
    $("#" + gridName).data('kendoGrid').editCell(theCell);     
}

function onRequestEnd(e) {
    debugger
    if (e.type == 'create') {
        NMDModelGridRefresh();
    }

    if (e.response) {
        AddNewRow();
    }
}

 

When the Kendo grid loads then, it is creating the new row, but after that it will load the records from the database and then refresh the screen and the new row is removing.

After that it is not calling AddNewRow(); method as onRequestEnd method is called once.

Can we somehow call this AddNewRow();  method after the grid is loaded with records.

Mihaela
Telerik team
 answered on 11 Apr 2025
1 answer
25 views

We recently upgraded Telerik to 2024.3.806.  Adding a reference to kendo.min.all.js to the Scripts file in the MVC project updated the styles in our grids, but the custom template no longer displays when clicking on a button for it from the grid.

Removing the reference to the new JS restores the functionality but breaks the styling, which makes it difficult for our users to navigate through the grid (control buttons are invisible until the user hovers over them; the new style fixes that issue).  Is there anything wrong with this code as written?  None of it has been changed.


@(Html.Kendo().Grid<ESGR.Icms.Core.Domain.QuickViewCasesDto>()
                 .Name("grid")
                 .Sortable()
             .Pageable(pager =>
             {
                 pager.Input(true);
                 pager.Info(true);
                 pager.Numeric(false);
                 pager.PreviousNext(true);
                 pager.PageSizes(new int[] { 25, 50, 100 });
             })
             .Columns(columns =>
             {
                 columns.Bound(column => column.FirstName).Title("First Name").Media("(min-width: 768px)");
                 columns.Bound(column => column.LastName).Title("Last Name").Media("(min-width: 768px)");
                 columns.Bound(column => column.DateOpened).Title("Date Opened").Width(200).Format("{0:MM/dd/yyyy}").Media("(min-width: 768px)");
                 columns.Bound(column => column.CaseNumber).Title("Case Number").Width(120).Media("(min-width: 768px)");
                 columns.Bound(column => column.CaseStatus).Title("Status").Width(120).Media("(min-width: 768px)");
                 columns.Bound(column => column.CaseState).Title("State").Width(80).Media("(min-width: 768px)");
                 columns.Bound(column => column.CaseRegion).Title("Region").Width(100).Media("(min-width: 768px)");
                 columns.Bound(column => column.AssignedTo).Title("Assigned To").Width(120).Media("(min-width: 768px)");
                 columns.Bound(column => column.EnteredBy).Title("Entered By").Width(120).Media("(min-width: 768px)");
                 columns.Bound(column => column.LastUpdate).Title("Last Update").Width(130).Format("{0:MM/dd/yyyy}").Media("(min-width: 768px)");
                 columns.Bound(column => column.CaseIdentifier).Title("Case Identifier").Width(80).Media("(min-width: 768px)").Hidden();
                 columns.Bound(column => column.Employer).Title("Employer").Width(80).Media("(min-width: 768px)").Hidden();
                 columns.Bound(column => column.OmbudsmanFirstName).Title("OmbudsmanFirstName").Media("(min-width: 768px)").Hidden();
                 columns.Bound(column => column.OmbudsmanLastName).Title("OmbudsmanLastName").Media("(min-width: 768px)").Hidden();
                 columns.Group(group => group.Title("Action Required").Width(150).Columns(info =>
                 {
                     info.Bound(x => x.TwoDayRequired).Title("2 Day").Width(50);
                     info.Bound(x => x.SevenDayRequired).Title("7 Day").Width(50);
                     info.Bound(x => x.FourteenDayRequired).Title("14 Day").Width(56);
                 }).Media("(min-width: 768px)")
                 );
                 columns.Bound(column => column.CaseID).Width(40).ClientTemplate("<a class='k-button manage' aria-label='ManageCase' href='" +
                 @Url.Content("~/ManageCase") + "?caseId=#= CaseID #'" + ">ManageCase</a>").Sortable(false)
                     .Title("Manage Case").Width(100).Media("(min-width: 768px)");
                 columns.Template("#=resColTemplate(data)#").Title("Records").Media("(max-width: 768px)");
                 columns.Command(command => command.Custom("MoreInfo").Click("showDetails")).Title("More Info").Width(90).Media("(min-width: 768px)");
             }).DataSource(ds => ds.Ajax()
              .Read(r => r.Url(@Url.Content("~/QuickViewCases?handler=Read")).Data("forgeryToken").Data("StatusSelection"))
                 .Model(m => m.Id(id => id.CaseID))
                 .PageSize(25))
                 .Pageable()
             )

 @*ViewDetail Modal view*@
 @(Html.Kendo().Window()
     .Name("Details")
     .Title("Case More Information")
     .Visible(false)
     .Modal(true)
     .Resizable()
     .Draggable(true)
     .Width(500)
 )

<script type="text/x-kendo-template" id="template">
    <div>
        <div class='viewdetails'>
            <ul class="form-group p-3 mt-2">
                <li><span class="b">Date Opened:&nbsp;</span>#= DateOpenedString #</li>
                <li><span class="b">Ombudsman:&nbsp;</span>#= OmbudsmanFirstName # #= OmbudsmanLastName # </li>
                <li><span class="b">Employer:&nbsp;</span>#= Employer #</li>
                <li><span class="b">Primary Point of Contact First Name:&nbsp;</span>#= PriPocFirst #</li>
                <li><span class="b">Primary Point of Contact Last Name:&nbsp;</span>#= PriPocLast #</li>
                <li><span class="b">Email:&nbsp;</span>#= Email #</li>
                <li><span class="b">State:&nbsp;</span>#= CaseState #</li>
                <li><span class="b">Summary:&nbsp;</span>#= Summary #</li>
            </ul>
        </div>
    </div>

</script>

<script>
 var detailsTemplate;
        
 $(document).ready(function() {
     detailsTemplate = kendo.template($("#template").html());
 });

//Open ViewDetail Window
function showDetails(e) {
    e.preventDefault();
    var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
    var wnd = $("#Details").data("kendoWindow");
    wnd.content(detailsTemplate(dataItem));
    wnd.center().open();
};

</script>

I am also including screenshots.  In the browser tools I can see that the data does load in the template, but it does not display on the screen.

Any ideas?

Eyup
Telerik team
 answered on 24 Mar 2025
1 answer
29 views

Hi,

I have a kendo grid. On copy the records from excel and paste on the kendo grid Paste event is triggered.

Suppose I have pasted 50 records from the excel to the grid. From that 50 records 10 records are invalid and I want to validate and show the error message for each row by row.

Please let me know how we can validate row by row on paste these 50 records from excel to kendo grid.

Events(events => events.Paste("onPaste"))
function onPaste(e) {

}

Ivaylo
Telerik team
 answered on 24 Mar 2025
1 answer
25 views

Recently I upgraded Kendo in a project from a 2020 version to the current version. It seems CancelText() and UpdateText() etc. of the command column in a grid have changed and now perform html escaping on the value. This results in the html code being shown to the user instead of what was intended.

Is it possible (and how) to get the old behaviour back?

The intended use is to have just an icon (not from the kendo set) on the button and no further text. So setting the CancelIconClass to "none" and putting the icon's html snippet in the text, used the achieve the intended result. But this method doesn't work any more.

Ivaylo
Telerik team
 answered on 04 Mar 2025
1 answer
31 views

Hi,

I wanted to Customize Kendo Grid Pagination as per the screenshot below. 

I tried the paging properties but nothing works.

I want the pagination style from 

 

 

To this

Anton Mironov
Telerik team
 answered on 04 Mar 2025
0 answers
42 views

As the title states, I have a legacy monolith that must be revived.

I need a few features, especially on the grid, and decided to upgrade Telerik. After a bit of struggle, I managed to run the application but the Telerik controls are by default very small compared to before and the new Size property doesn't seem to be doing much:

Before:

Now:

As it can be seen, the grid shrunk. I do not have a lot of custom CSS on this site but the baseline theme was Start Bootstrap v2 (Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com)). Not sure if the original theme can still be found.

DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 25 Feb 2025
1 answer
25 views

I am not able to download more than 30k records into excel. Sometimes i am getting 500 error some time not but excel is not downloaded any time.

This is my code

 

@(Html.ReportsGrid
<apexportal.WebService.Models.AuditReportResult>()
    .HtmlAttributes(new { @style = "height: 500px;" })
    .Name("AuditReportGrid")
    .Excel(e => { e.FileName("AuditReport.xlsx").AllPages(true); })
    .Events(e => { e.ExcelExport("excelExportCheck"); })
    .AutoBind(false)
    .DataSource(datasource => datasource
    .Custom()
    .Type("aspnetmvc-ajax")
    .Transport(t => t.Read(r => r.Action("Read", "AuditReport").Data("getAdditionalData")))
    .Schema(s => s
    .Data("Data")
    .Model(model =>
    {
    model.Id(itm => itm.VR_Audit_LogID); //("VR_Audit_LogID");
    model.Field("VendorID", typeof(string));
    model.Field("ActionTime", typeof(DateTime));
    model.Field("ReviewedDate", typeof(DateTime));
    })
    .Total("Total")
    )
    .ServerSorting(true)
    .ServerPaging(true)
    .ServerFiltering(true)
    .ServerGrouping(false)
    .ServerAggregates(false)
    .Events(events => events.Error("error_handler"))
    )
    .Columns(columns =>
    {
    columns.Bound(portal => portal.VR_ID).Title("VR ID".Translate())
    .HeaderHtmlAttributes(new { @class = "NumericHeaderAlign" }).HtmlAttributes(new { @class = "NumericRowAlign" }).Width(180)
    .Filterable(x => x.Cell(y => y.Template("NumericFilter")));
    if (userACL.IsRegistrationEnabled &&!userACL.IsCustomerRegistrationEnabled)
    {
    columns.Bound(portal => portal.VendorID).Title("Vendor ID".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    }
    if (userACL.IsCustomerRegistrationEnabled)
    {
    columns.Bound(portal => portal.VendorID).Title("Entity ID".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    }
    columns.Bound(portal => portal.CompanyName).Title("Company Name".Translate())
    .ClientTemplate("#=buildCompanyNameLink(CompanyName, '" + @Url.Action("GetCompanyUrl") + "')#")
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(200);
    columns.Bound(portal => portal.ModifiedFieldName).Title("Field Name".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(250);
    columns.Bound(portal => portal.DecryptedOriginalValue).Title("Original Value".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.DecryptedNewValue).Title("New Value".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.ChangedBy).Title("Changed By".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.ChangedByFirstName).Title("Changed By First Name".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.ChangedByLastName).Title("Changed By Last Name".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    columns.Bound(portal => portal.RegistrationType).ClientTemplate("#= RegistrationType == null ? '' : TranslateText(RegistrationType) #").Title("Registration Type".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    if (userACL.IsCustomerRegistrationEnabled && userACL.IsRegistrationEnabled)
    {
    columns.Bound(portal => portal.ProfileType).ClientTemplate("#= ProfileType == null ? '' : TranslateText(ProfileType) #").Title("Profile Type".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(150);
    }
    columns.Bound(portal => portal.Action).ClientTemplate("#= Action == null ? '' : TranslateText(Action) #").Title("Action".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    //columns.Bound(portal => portal.PRIMARY_KEY).Title("Primary Key".Translate()).HtmlAttributes(new { @style = "white-space: nowrap;" }).Width(110);
    columns.Bound(portal => portal.DataSource).Title("Data Source".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    columns.Bound(portal => portal.ActionTime).Title("Action Time".Translate()).Format("{0:G}")
    .HeaderHtmlAttributes(new { @class = "DateHeaderAlign" }).HtmlAttributes(new { @class = "DateRowAlign" }).Width(150);
    columns.Bound(portal => portal.ReviewMode).ClientTemplate("#= ReviewMode == null ? '' : TranslateText(ReviewMode) #").Title("Review Action".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    columns.Bound(portal => portal.ReviewedBy).Title("Reviewed By".Translate())
    .HeaderHtmlAttributes(new { @class = "StringHeaderAlign" }).HtmlAttributes(new { @class = "StringRowAlign" }).Width(110);
    columns.Bound(portal => portal.ReviewedDate).Title("Reviewed Date".Translate()).Format("{0:G}")
    .HeaderHtmlAttributes(new { @class = "DateHeaderAlign" }).HtmlAttributes(new { @class = "DateRowAlign" }).Width(150);
    }
    )
    .Filterable(filterable => filterable
    .Extra(false)
    .Operators(operators => operators
    .ForDate(str => str.Clear()
    .IsNotEqualTo("Is not equal to".Translate())
    .IsGreaterThanOrEqualTo("Is after or equal to".Translate())
    .IsGreaterThan("Is after".Translate())
    .IsLessThanOrEqualTo("Is before or equal to".Translate())
    .IsLessThan("Is before".Translate())
    .IsNull("Is Null".Translate())
    .IsNotNull("Is Not Null".Translate()))))
    )
    }

 

    @Html.GridErrorHandler()
    @Html.GridResizeHandler("AuditReportGrid")
    @CustomHtml.GridContextMenu(Html, "AuditReportGrid")
    @CustomHtml.EnableFormValidation("SearchForm", "searchbtn")

Anton Mironov
Telerik team
 answered on 21 Feb 2025
1 answer
25 views

Here is the grid before I click the first Edit button:

And then after:



Most of the rows have disappeared.
The h-scrollbar is gone.  Typically I can't scroll right. Seems a few cases, playing around with it, the arrow-keys scrolled right but the header row became detached, i.e. did not scroll right with the body. 

Anyone know what might be causing this?  I"ve been getting this problem on 2024 Q4 and 2025 Q1. 

I have enabled fairly strict CSP headers per management requirements and am using at least 3 editor templates. I've added this line:
@(Html.Kendo().DeferredScriptFile(nonce))
to the bottom of each EditorTemplate file (not sure if that's correct).  Removing that line seems to fix the grid-distortion but also loses the editor template itself. 

 

 

 

Anton Mironov
Telerik team
 answered on 20 Feb 2025
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?