Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. @page "/grid/templates"
  2.  
  3. @using TelerikBlazor.App.Models
  4. @inject NorthwindContext nwContext
  5.  
  6. <h4> Row Template </h4>
  7.  
  8. <KendoGrid Data=@GridData Height="@Height">
  9. <RowTemplate Context="product">
  10. @if (selectedId == product.ProductId)
  11. {
  12. <td colspan="2">
  13. <KendoButton Icon="close" OnButtonClick="@(()=> SelectedProduct(null))">Close</KendoButton>
  14. <div class="card mb-3">
  15. <div class="row no-gutters">
  16. <div class="col-md-1">
  17. <img class="rounded-circle ml-3 mt-3" src="@($"/images/{product.ProductId}.jpg")" alt="Alternate Text" />
  18. </div>
  19. <div class="col-md-11">
  20. <div class="card-body">
  21. <h5 class="card-title">@product.ProductName</h5>
  22. <div class="form-row">
  23. <div class="form-group col-md-6">
  24. <label>Quantity Per Unit</label>
  25. <input type="text" class="form-control" value="@product.QuantityPerUnit">
  26. </div>
  27. <div class="form-group col-md-6">
  28. <label>Reorder Level</label>
  29. <input type="text" class="form-control" value="@product.ReorderLevel">
  30. </div>
  31. </div>
  32. <div class="form-row">
  33. <div class="form-group col-md-6">
  34. <label>Unit Price</label>
  35. <input type="text" class="form-control" value="@product.UnitPrice">
  36. </div>
  37. <div class="form-group col-md-6">
  38. <label>Units in Stock</label>
  39. <input type="text" class="form-control" value="@product.UnitsInStock">
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </td>
  47. }
  48. else
  49. {
  50. <td onclick="@(()=> SelectedProduct(product.ProductId))">
  51. <img class="rounded-circle" src="@($"/images/{product.ProductId}.jpg")" alt="Alternate Text" />
  52. @product.ProductName
  53. </td>
  54. <td>
  55. @(String.Format("{0:C2}", product.UnitPrice))
  56. </td>
  57. }
  58. </RowTemplate>
  59. <KendoGridColumns>
  60. <KendoGridColumn Field=@nameof(Product.ProductName) Title="Product Name" />
  61. <KendoGridColumn Field=@nameof(Product.UnitPrice) Title="Unit Price" />
  62. </KendoGridColumns>
  63. </KendoGrid>
  64.  
  65. @functions {
  66. int? selectedId;
  67. public IEnumerable<Product> GridData { get; set; }
  68. public int Height = 500;
  69. void SelectedProduct(int? id)
  70. {
  71.  
  72. selectedId = id;
  73. StateHasChanged();
  74. }
  75. protected override async Task OnInitAsync()
  76. {
  77. await LoadData();
  78. }
  79.  
  80. private async Task LoadData()
  81. {
  82. GridData = await nwContext.Products.Take(10).ToListAsync();
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement