|
5 | 5 | } |
6 | 6 | <meta charset="utf-8" /> |
7 | 7 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
8 | | -<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self'; script-src 'self' https://kendo.cdn.telerik.com https://code.jquery.com/ 'nonce-Telerik-CSP-Examples'; style-src 'self' 'unsafe-inline' https://kendo.cdn.telerik.com; font-src 'self' data:;" /> |
| 8 | +<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' data:; script-src 'self' https://kendo.cdn.telerik.com https://code.jquery.com/ 'nonce-Telerik-CSP-Examples'; style-src 'self' 'unsafe-inline' https://kendo.cdn.telerik.com; font-src 'self' data:;" /> |
9 | 9 | <title>@ViewData["Title"] - Telerik.Examples.Mvc</title> |
10 | 10 |
|
11 | 11 | @{ |
12 | | - var kendoVersion = "2023.2.718"; |
| 12 | + var kendoVersion = "2023.3.1010"; |
13 | 13 | } |
14 | | -<link rel="stylesheet" href="https://kendo.cdn.telerik.com/themes/6.6.0/default/default-ocean-blue.css"> |
| 14 | +<link rel="stylesheet" href="https://kendo.cdn.telerik.com/themes/7.0.1/default/default-ocean-blue.css"> |
15 | 15 |
|
16 | 16 | <script src="https://code.jquery.com/jquery-3.7.0.min.js" |
17 | 17 | integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" |
|
20 | 20 | <script src="https://kendo.cdn.telerik.com/@kendoVersion/js/kendo.all.min.js"></script> |
21 | 21 | <script src="https://kendo.cdn.telerik.com/@kendoVersion/js/kendo.aspnetmvc.min.js"></script> |
22 | 22 |
|
23 | | -<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> |
| 23 | +@*<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />*@ |
24 | 24 | <link rel="stylesheet" href="~/css/site.css" /> |
25 | 25 |
|
26 | 26 | @(Html.Kendo().Grid<Telerik.Examples.ContentSecurityPolicy.Models.DetailProductViewModel>() |
|
31 | 31 | columns.Bound(p => p.ProductName) |
32 | 32 | .ClientTemplate(Html.Kendo().Template().AddHtml( |
33 | 33 | @"<div class='product-photo' |
34 | | - style='background-image: url(" + @Url.Content("~/shared/foods/${data.ProductID}.jpg") + ");'></div><div class='product-name'>${ data.ProductName }</div>")).Width(300); |
35 | | - columns.Bound(p => p.UnitPrice).Title("Price").Width(105); |
| 34 | + style='background-image: url(" + @Url.Content("~/shared/foods/${data.ProductID}.jpg") + ");'></div><div class='product-name'>${ data.ProductName }</div>")) |
| 35 | + .EditorTemplateComponentName("String") |
| 36 | + .Width(300); |
| 37 | + columns.Bound(p => p.UnitPrice).EditorTemplateComponentName("Currency").Title("Price").Width(105); |
36 | 38 | columns.Bound(p => p.Discontinued).Title("In Stock").Width(130) |
37 | 39 | .ClientTemplate(Html.Kendo().Template().AddHtml("<span id='badge_${data.ProductID}' class='badgeTemplate'></span>")); |
38 | | - columns.Bound(p => p.Category.CategoryName).Title("Category").EditorTemplateName("ClientCategoryEditor").ClientGroupHeaderTemplateHandler("CategoryTemplateHandler").Width(125); |
| 40 | + columns.Bound(p => p.Category).ClientTemplateHandler("CategoryTemplateHandler").Title("Category").EditorTemplateComponentName("ClientCategoryEditor").Width(125); |
| 41 | + columns.Bound(p => p.Category.CategoryName).ClientGroupHeaderTemplateHandler("CategoryHeaderTemplateHandler").Hidden(); |
39 | 42 | columns.Bound(p => p.CustomerRating).Title("Rating").Width(140).Editable("returnFalse").ClientTemplate(Html.Kendo().Template().AddComponent(rating => rating.Rating() |
40 | 43 | .Name("rating_${data.ProductID}") |
41 | 44 | .Min(1) |
|
44 | 47 | .HtmlAttributes(new { data_bind = "value: CustomerRating" }) |
45 | 48 | .Selection("continuous") |
46 | 49 | )); |
47 | | - columns.Bound(p => p.Country.CountryNameLong).Title("Country").EditorTemplateName("Country").ClientTemplate(Html.Kendo().Template().AddHtml( |
| 50 | + columns.Bound(p => p.Country).Title("Country").EditorTemplateComponentName("Country").ClientTemplate(Html.Kendo().Template().AddHtml( |
48 | 51 | @"<div class='k-text-center'><img src='" + @Url.Content("~/shared/country-flags/${data.Country.CountryNameShort}.png") + "' alt='${ data.Country.CountryNameLong}' title='${ data.Country.CountryNameLong}' width='30' /></div>")).Width(120); |
49 | | - columns.Bound(p => p.UnitsInStock).Title("Units").Width(105); |
50 | | - columns.Bound(p => p.TotalSales).Title("Total Sales").Width(140).Format("{0:c}"); |
51 | | - columns.Bound(p => p.TargetSales).Editable("returnFalse").Title("Target Sales") |
| 52 | + columns.Bound(p => p.UnitsInStock).EditorTemplateComponentName("Integer").Title("Units").Width(105); |
| 53 | + columns.Bound(p => p.TotalSales).Title("Total Sales").Width(140).Format("{0:c}"); |
| 54 | + columns.Bound(p => p.TargetSales).Editable("returnFalse").Title("Target Sales") |
52 | 55 | .ClientTemplate(Html.Kendo().Template().AddComponent(sparkline => sparkline.Sparkline() |
53 | 56 | .Name("chart_${data.ProductID}") |
54 | 57 | .Legend(legend => legend |
|
140 | 143 | } |
141 | 144 | } |
142 | 145 | function CategoryTemplateHandler(data){ |
| 146 | + return `${data.Category.CategoryName}`; |
| 147 | + } |
| 148 | + function CategoryHeaderTemplateHandler(data){ |
| 149 | +
|
143 | 150 | return `Category: ${data.value}, Total Sales: ${kendo.format('{0:c}')}, ${data.aggregates.TotalSales.sum}`; |
144 | 151 | } |
| 152 | + function CountryTemplateHandler(data){ |
| 153 | + return `<div class='dropdown-country-wrap'><img src='@Url.Content("~/shared/country-flags/${data.CountryNameShort}.png")' alt='${data.CountryNameLong}' title='${data.CountryNameLong}' width='20' /><span>${data.CountryNameLong}</span></div>`; |
| 154 | + } |
145 | 155 | function onDataBound(e) { |
146 | 156 | var grid = this; |
147 | 157 | var rows = $("tr"); |
|
0 commit comments