This project is read-only.

How to display list of content items using Telerik Grid component

Topics: Customizing Orchard, Writing modules, Writing themes
Jul 17, 2012 at 10:14 AM


I'm begginer in the Orchard CMS. I would like to create Content Type composed from different parts and fields which I know before. I want this content type to be enumerable ie I use content part List, I want to list it using telerik components.

For example my content type is Product and I specify its fields: Price, SKU apart from default: user(who created it) and creation time fields. Moreover the product contains also image gallery, ie image gallery content part.. I want the list of products to be shown using Telerik component Grid, including creation time and user name.

Is it better to create the whole module specifying all its fields(price,SKU) and its templates or is there any way to just take what has been already created in orchard as a content type and display it different way(using telerik)..

thanks for any advice ;) Tomas

Jul 17, 2012 at 7:46 PM

It's not necessary to create a module to create new content types, parts and fields, as you can do so via the admin. However, if you want to override the rendering of a content item (e.g. a List, or even better: a Projection), you either need to create a module or a theme that will host your Razor template.

Jul 18, 2012 at 6:27 PM

Many thanks for your comment sfmskywalker!

So I have stepped up a bit and created my own projection by defining a query which returns a set of content items of known content type. I would like to pick up certain content parts from these returned content items and display them in the list(or using telerik component). Using shape tracing tool I have found the view template where to write my custom layout:


but from the Model variable in the template I can not get the data I want because it is way too high above from the content parts data.

a good example of what I want: let's say I want to render product catalog as defined in this tutorial:

but I want only to render a list which consists from items defined as:

  1. name of the owner who created the product
  2. name of the product.
  3. publish date of the product

and I need to render it at one place, i.e., not separately in their own part views.

Maybe a good idea would be to let these content parts render their content but dont display them just collect the rendered results which then I display in the telerik component, but I'm not sure if this could work.

Jul 26, 2012 at 4:47 PM

No problem.

First of all, let me advise against overriding Parts.ProjectionPart.cshtml. If you do that, ALL projections will be rendered using that template. Instead, try and see if you can pick an alternate, e.g. Parts.ProjectionPart-Product.cshtml. If there's no suitable alternate available, I think the Projections module enables you to specify your own alternate (not sure though).

To determine what shapes to render and what shapes to hide, you could use to control the zones and position where you want each part to render. If you don't want to do that, but instead want complete control over rendering a content item in summary view, then all you have to do is to create a template for the content item. Use Shape Tracing to pick a suitable alternate, e.g. Content-Product.Summary.cshtml. Inside this template, the Model will provide access to the ContentItem. From there, you can access the ProductPart and its properties and content fields, e.g.: Model.ContentItem.ProductPart.Name. Or if you want to access the owner of the item, use the something like this: Model.ContentItem.CommonPart.Owner.