First, I've already tried showing a graph using a FileContentResult and the write method. But I can't use both since my requirement requires me to show a grid on 1 tab and a graph on the next tab. So I need to store the graph in a ViewBag and render it to a view, but I'm unable to do that. Is there anyway around?
Note: I'm using the Chart object from System.Web.Helpers namespace.
Thanks,
czetsuya
You can render chart as partial view.
you can use System.Web.Helpers namespace here an example:
http://msdn.microsoft.com/en-us/library/system.web.helpers.chart(v=vs.99).aspx
A chart is just an image. Link to it.
<img src="#Html.Action("ImageAction")" alt="Chart" />
I found a solution (without executing the same query), I stored the image in a cache and later refer to it via a unique key. Unfortunately, I needed to issue another http request for it. See post here: http://czetsuya-tech.blogspot.com/2012/02/how-to-render-chart-object-in-view-in.html
Related
I have an application where I need to display metrics. The application needs to display a separate vertical section for each metric. When I started this, there were only 5 metrics so I naively created a template with 5 regions, one for each metric I needed to display. Now, new metrics need to be added and I want to avoid adding "hardcoded" region divs in the template. I want to refactor this and create the required regions dynamically at startup time based on some configuration data.
So I have been looking at the latest Marionette release and in question "Dynamically add regions to Marionette layout", Derick Bailey mentions that Marionette v1.0 supports dynamic regions in Layouts through addRegion(), as in:
var layout = new MyLayout();
layout.render()
layout.addRegion("someRegion", "#some-element");
layout.someRegion.show(new MyView());
I have tried that in my code (using Marionette 1.0.2) and I am not getting it to work. I don't have a div with id="some-element" in my template and I suspect this could be the reason. I was hoping that Marionette would create that div itself.
Perhaps my expectation of what dynamically adding a region means is wrong. So my first question is: when adding regions dynamically to a layout, must the element id passed in the addRegion() function already exist in the layout?
If so, then I am back to the problem of having to "burn" in the template those divs for the regions to attach themselves too. My follow-up question is then: What is the best way of doing this in a data-driven fashion? Is it a matter of writing my own render() function so that the right set of divs get created? Or perhaps providing my Layout with a model object that will contain data which the template can then iterate through to create the necessary divs? How do we add regions dynamically to a Layout object if we don't know in advance how many regions we will actually need?
Aa #aaronfay specified, we need to use jQuery to create the element on the page. Here is some sample code:
var layout = new MyLayout();
layout.render()
var regionName = "dynamicRegion";
layout.$el.append('<div id="'+regionName+'"></div>');
layout.addRegion("someRegion", "#"+regionName);
layout.someRegion.show(new MyView());
I believe you would need to use jQuery (or similar) to create the element on the page. A Region expects the element to exist.
Otherwise, I believe your answer is here.
Im using play framework and rendering PDF usin rednerPDF() method.
I would like to display some part of content always be in new page.
For Example I have two tables, One table should be in first page and another table should in next page instead of continue from first page. The first table contents are dynamic and we can't sure the height of the table.
Is it possible?
Is it possible?Yes.
You said one table(first one) should be in first page,and again you said its content is dynamic.Now my question is it span over pages and in the next page you want to write second table?This is a generic scenario and what you mentioned is specific one.
You can start trying using two properties of PdfPTable setSplitLate() and setSplitRows()(just google it out for details read Itext In Action).Just keep Two table as two Rows of outer table.set those two property for inner as well as outer in some way as you want(i.e generic case/Specific case).
Another alternative way is use writeSelectedRows() method over PdfContentByte(I don't konw which Object you gonna use for manipulating pdf but you can get it from PdfWriter,*PdfStamper* by using getDirectContent/*UnderContent*/OverContent) after generating table.To use this method you have to set total width of the table so the height can be calculated by method getTotalHeight of PdfPTable.If You use this height properly you absolutely know where your table ends.But all these specific part you have to read & understand first.
With yahp you can use a special html tag to force a page break
<yahp:pb />
we can achieve this by page-break-after:always
Please refer
Alternate to PDF for dynamically generated document with page breaks
I have just setup a new Sitecore 6.6 MVC application and all is going well.
I need a breadcrumb trail and found this:
http://nuget.org/packages/MvcSiteMapProvider
I have set it up and it renders the
#Html.MvcSiteMap().SiteMap() correctly
but
it doesn't render anything for bread crumb:
#Html.MvcSiteMap().SiteMapPath()
If I debug into the SiteMapPathHelperModel.cshtml I can see that there are no nodes in my Model.
First question is, can and should I use:
http://nuget.org/packages/MvcSiteMapProvider
in MVC with Sitecore.
Second question is:
If you think it is ok to use this, do you have any idea why it doesnt render my bread crumb but it renders the menu?
I have never used SiteCore, so I don't know how it is set up exactly. However, MvcSiteMapProvider is flexible and can accommodate many scenarios.
The SiteMapPath() will render if you navigate to one of the URLs that are registered in the Mvc.sitemap XML file. Note that in most cases you need to register them with a controller and action attribute set. The whole principle is based on matching a unique node within the sitemap to a route, so you need to ensure that both the node and the route of the request have matching RouteValues dictionaries.
See the MvcMusicStore demo in the source code download if you need to see a working implementation to get started, or have a look at this tutorial:
http://www.shiningtreasures.com/post/2013/08/07/MvcSiteMapProvider-40-a-test-drive
How can i implement a Section View(like in IOS) in Windows8 ListView ?
I want to break down the Listview into different Sections.
Any Directions ?
ListViews have a property called groupDataSource that lets you define how the items are grouped. You might want to look at the Grid App template in Visual Studio, which has data already set up in this way. You can also take a look at this tutorial: http://msdn.microsoft.com/en-us/library/windows/apps/hh465464.aspx
If you want any more info, you will have to be a bit more specific with your line of questioning.
In my Netflix post on codefoster.com I tried to show grouping in its simplest form. When you have a JS array, you simply make a Binding.List out of it and then you just call createGrouped sending it two lambda functions telling it how to group. Then like #Paul said, you'll get those different sections automatically in your ListView. Hope that helps.
let's consider a web application built using MVC concept. If my application generates some chart images dynamically based on the user input and a database I wish to know which component the image generation process will belong to: controller or view?
It's controllers job to generate the image and the view component to display it?
yes, but i would make a class that generate the chart which would be invoked by the controller
in short, yes you are correct.
You are correct, a controller should generate the image and the view should display it. This would most likely be handled by a setting the "src" attribute of an image to a controller/dispatch that streams binary data, but it's up to you how exactly you implement that.
The controller is responsible for coordinating the generation of the image. The image can be generated by an HttpHandler, some other component capable of generating the stream or static resource that should be returned.
As an addition to the other answers, here's an example.