I'm new to the new umbraco grid functionality and I have a question about it.
I have a page with an article where I use the grid functionality to show some image and text besides that image. This is working fine.
In the properties of that page I have put a checkbox for saying that the article is for sale or not, when checked the product should automatically appear on a for sale page.
I can get the product that is for sale on that page, but now I also want to show the image and text on that page. I've created a List with a custom viewmodel to hold the content for every product that is for sale. The problem is with providing the JObject to the GetGridHtml function. This function wants a string and I'm providing the property which results in an error.
What is the best way to get the content for the grid to show on that separate page?
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var home = CurrentPage.Site();
List<ForSaleItemsViewModel> forSaleItemsVM = new List<ForSaleItemsViewModel>();
if(home.Children.Any())
{
foreach(var childPage in home.Children)
{
if(childPage.Children.Any())
{
foreach(var child in childPage.Children)
{
if(child.HasProperty("ForSale") && child.ForSale)
{
forSaleItemsVM.Add(new ForSaleItemsViewModel
{
ID = 1,
Content = child.Content,
Sold = child.Sold
});
}
}
}
}
}
}
<div class="container">
@foreach(var item in forSaleItemsVM)
{
if (item.Sold)
{
<span>SOLD!</span>
}
CurrentPage.GetGridHtml(item.Content.ToString(), "bootstrap3");
}
</div>