Multiple data on same page

Topics: Customizing Orchard, General
Jul 28, 2013 at 10:22 AM
I need to display data from different tables on same view/ Page. How I can achieve this in Orchard. Do I need to create different drivers/ parts/views. Please help.

Jul 28, 2013 at 5:59 PM
There are various ways you can achieve this. One way is creating a controller that works with a couple o IRepositories that access your tables. Another is creating a custom part that does the same (but since it's a part you can attach it to a content type, perhaps even creating a widget).
Or maybe you should create multiple custom parts to create various widget types.
With the little information you have given, it's hard to give good advice.
Jul 28, 2013 at 6:16 PM
Edited Jul 28, 2013 at 6:19 PM
The best (but my own opinion) is to create a Content Type which displays the whole thing, what you call table could be a part in Orchard language.
So you start by creating a part for each table, and you create a content type with each part.
Each part has its own display drivers but as Orchard unit of display is the Content Item you will get coherence.
Orchard uses a shape for each part, but you have total control of what is displayed.
When Orchard displays a content item, it displays a list of shapes (one for each part, basically).
The joke is when displaying each content item to favour some shapes for displaying several parts using the common content item as a pivot to swap between parts data.
Flexible as possible, only imagination can limit, but need some reflexion and many Time+lines of coding.
Aug 1, 2013 at 3:40 PM
Hi Friends,
Thank you for replying. I am thinking on following lines. Please suggest if this is correct.
  1. Create a single widget.
  2. This widget will display data from different controls or controller methods.
  3. Will implement IRepositories for retrieving or saving data.
  4. The view of the widget will have different calls direct or Ajax.
Aug 2, 2013 at 6:28 AM
It depends. In any case, the data to be displayed will probably come from your widget's driver, and input would be posted back to a controller.
This controller would have a couple of repositories injected to persist the data (or delegate it to a service class).
Aug 3, 2013 at 3:34 PM
Hi sfmskywalker,
I want to create a widget which will be part of most of pages in my new site. This widget/control will have a no of tabs. By default when page loads the data in the first tab should be displayed inside widget/control. Now whenever user navigates/ clicks any another tab a Ajax call will be done to retrieve data for that tab. There will be total six such tabs. My aim is to achieve this functionality in best possible way which gives me best performance too. If you can visualize my scenario can you please give me some guidelines on how to achieve this. If possible with some code example.
Aug 4, 2013 at 6:15 AM
I see. What you could do is implement a controller that returns either HTML or JSON, depending on what it is you want to render. If you want to go fast, return JSON and use a library such as Knockout to bind your UI against the returned JSON.