Skip to content

Instantly share code, notes, and snippets.

@KristianMariyanov
Created May 10, 2020 12:03
Show Gist options
  • Save KristianMariyanov/c5e7a3fb2869da6e5e1d844506956725 to your computer and use it in GitHub Desktop.
Save KristianMariyanov/c5e7a3fb2869da6e5e1d844506956725 to your computer and use it in GitHub Desktop.
<TelerikGrid Data=@GridData
Height=@Height
Sortable=true
Pageable=true>
<GridColumns>
<GridColumn Field=@nameof(Product.ProductId) Sortable="false" Title="Id" />
<GridColumn Field=@nameof(Product.ProductName) Title="Product Name" />
<GridColumn Field=@nameof(Product.UnitPrice) Title="Unit Price">
<Template>
@(String.Format("{0:C2}", (context as Product).UnitPrice))
</Template>
</GridColumn>
</GridColumns>
</TelerikGrid>
@code {
public IEnumerable<Product> GridData { get; set; }
string Height = "400px";
protected override void OnInitialized()
{
List<Product> products = new List<Product>();
for (int i = 0; i < 100; i++)
{
products.Add(new Product()
{
ProductId = i,
ProductName = "Product " + i.ToString(),
SupplierId = i,
UnitPrice = (decimal)(i * 3.14),
UnitsInStock = (short)(i * 1),
});
}
GridData = products.AsQueryable();
}
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public int? SupplierId { get; set; }
public decimal? UnitPrice { get; set; }
public short? UnitsInStock { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment