ASP.NET MVC Razor Chart within View rendered with Model - asp.net-mvc

This seems like something so easy, and i am sure it is, but i cant figure out how to do it.
On my view i want a table and a chart, both sourced from the model.
The only options i have found is to create the chart inline (which then is the only thing displayed), use inside an img, or an Action or trying to write the bytes direct as a stream, all of which doesn't seem to support passing a model object.
How can i insert a chart in a view using the views model object so it coexists, either coding directly into the View or via some other method?

I discovered a way to do it from the view using
System.Web.UI.DataVisualization.Charting.Chart chart;
/* populate chart from Model here */
HtmlTextWriter writer = new HtmlTextWriter(Html.ViewContext.Writer);
chart.RenderControl(writer);

Related

Recommended way to do the search and populating the grid in ASP.NET Core MVC 6

I am creating a project where I need to create a view with search textboxes and a dropdown which would be populated from the server. Same view also have a grid which would be populated based on the search criteria enter/selected by user.
I want to know what would be the design of the page in terms of showing both on same page. Should I create a partial view for the grid or Search panel or add both in the single view?
Note that dropdown list would need to be populated from the ViewModel. So what is the common practice in the situation. I am new to this I have done few pages but with lot of code, session and ViewBags and I think I am not following recommended practice.
Actually, the design for your web application is according to your requirement.
For example, if you want grid to work with other datasource or view, you could build it as a component, then if you want to use it, you could directly use this component to avoid write the same codes for multiple time.
If you want to use same grid to show in some other page, you could build it a partial view, then you could directly call this view to show something.

how to add bootstrap grid in side of my main RTE in umbraco?

I have a Document Type which has a main content box (RTE). now I wand add a grid layout inside it and add "Partial View Macro" to this grid cells.
for example create a 1*3 grid and add a summery card inside of each cell. like this view :
in this case I implement card as a "Partial View Macro"
You should be able to create a macro that can point to a separate node that contains a Grid Layout property and similar to a template calling the GetGridHtml() extension method, you can call it from your macro code like this:
Html.GetGridHtml(gridNode, "gridLayourPropertyName");
Where gridNode is an IPublishedContent object that your macro can have as a parameter, and "gridLayourPropertyName" is the Grid Layout property of that node.
I haven't used this technique using a Macro from a RTE, but I've done something similar to build a grid within another grid layout. This may not be the best technique to follow and I'd strongly recommend looking into replacing the RTE property with a grid layout. You can use RTE as a grid editor, so you could migrate your existing property data and then you will have all the flexibility to create/configure/customize grid editors using current best practices to meet your requirements.

Kendo UI Grid data bind to two table DB

I am trying to figure out two things. First, is it even possible. Second, am I on the correct path?
I am making an ASP.net Kendo UI Grid that just needs a very simple two table, inner join from an Entity Framework model. The issue is that one of the fields is incredibly large. It requires me to set the value to the json object size to max int value just to be able to return a single table result.
Because the resulting set is so large, I do not seem to be able to use a view model. It just returns a size limit error on that as well. Is there a way to return a very large dataset from two tables to a single Kendo UI grid? I have tried every suggestion from every existing answer on Stack Overflow and the Telerik forums.
I don't really think that some user need information which cannot be handled by default json object size.
May be should load first 50-100 characters from that field to grid and if user click on cell load rest of the data.
Another way is using virtual scroll or paging.
If kendo model cant handle your field size, you can add columnt to each row with view large data button and open window with text field loaded from db on click.

Sitecore Controller Rendering DataSource

I have a component in Sitecore that can be used in the middle section of the page. It shows a video and is setup as a controller rendering in Sitecore. I have been able to get this to work by setting the DataSource on the rendering on the page item.
I have another component for the middle section of the page. This is a list of videos. Each video output has the exact same HTML as the rendering mentioned in the previous paragraph. I'm trying to call the controller rendering (mentioned above) in the rendering for this list rendering something like this -
#Html.Sitecore().Controller("VideoController", "Display")
I'm trying to set the DataSource in/before calling the .Controller function but I haven't found a way to do it. I'm looking for some answers on how to set the DataSource or call a controller rendering from another rendering.
Thanks
This should be possible by statically binding the rendering and then adding the datasource as a parameter:
#Html.Sitecore().Rendering("<your rendering definition item id>", new { DataSource = "<your datasource item id>" })

charts in Partial view

I want to create partial views such that each partial view corresponds with one type of chart (say bar chart, pie chart etc.). The chart should be generated on the partial view just by passing the model to it.
I am working on the charts for the first time so not very much aware of the components/libraries available. All the example I seem to find on internet works by creating all the charts at the time of requirement and saving the for further use. Eg. http://czetsuya-tech.blogspot.in/2012/02/how-to-render-chart-object-in-view-in.html#.Uk_r_oaGoUU
Please let me know if any clarification is required.
While searching for similar thing I found the following that I think could be helpful to you as well:
http://forums.asp.net/t/1874913.aspx

Resources