Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I populate a multi-dimensional Array with my Model properties
    primarykey
    data
    text
    <p>I have the following view that is responsible for displaying a chart, currently for testing purposes I am passing static values for the array as follow:- </p> <pre><code>@model IEnumerable&lt;Medical.Models.Session&gt; &lt;script src="../../Scripts/jqplot/jquery.jqplot.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jqplot/jqplot.barRenderer.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jqplot/jqplot.categoryAxisRenderer.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jqplot/jqplot.pointLabels.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jqplot/jqplot.dateAxisRenderer.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jqplot/jqplot.highlighter.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jqplot/jqplot.cursor.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;p&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { line1 = [['23-May-2008', 578.55], ['20-Jun-2008', 566.5], ['25-Jul-2008', 480.88], ['22-Aug-2008', 509.84], ['26-Sep-2008', 454.13], ['24-Oct-2008', 379.75], ['21-Nov-2008', 303], ['26-Dec-2008', 308.56], ['23-Jan-2009', 299.14], ['20-Feb-2009', 346.51], ['20-Mar-2009', 325.99], ['24-Apr-2009', 386.15], ['01-Apr-2012', 786.15]]; var plot1 = $.jqplot('chart1', [line1], { title: 'Data Point Highlighting', axesDefaults: { pad: 1.2 }, axes: { xaxis: { renderer: $.jqplot.DateAxisRenderer, tickOptions: { formatString: '%d/%b/%Y' } }, yaxis: { tickOptions: { formatString: '%.2f'} } }, highlighter: { show: true, sizeAdjust: 7.5, tooltipLocation: 'nw' // , formatString: '&lt;b&gt;%s&lt;/b&gt;' }, cursor: { show: true, tooltipOffset: 6 } }) }); &lt;/script&gt; &lt;div id = "chart1"&gt; &lt;/div&gt; </code></pre> <p>But what I am trying to do is to populate the Line1 multi-dimentional Array with the values of the Model properties(instead of the static values shown above), which contains <code>Date &amp; Result</code> ,, something similar to this :-</p> <pre><code>@foreach (var item in Model) { //code goes here,, line1 [1,1] = [item.Date , item.Result] // only for describing what i am trying to do } </code></pre> <p><strong>-:::EDITED:::-</strong> The Action method that build the Model looks as follow:-</p> <pre><code>public PartialViewResult showpatientsessions(int Medicine, int PatientID) { var m = repository.showpatientsessions(Medicine, PatientID).OrderByDescending(d =&gt; d.Date); return PartialView("_showpatientsessions",m); } </code></pre> <p>The model is:-</p> <pre><code>public partial class Session { public int LabTestID { get; set; } public int VisitID { get; set; } public decimal Result { get; set; } public Nullable&lt;System.DateTime&gt; Date { get; set; } public string Comment { get; set; } public virtual LabTest LabTest { get; set; } public virtual Visit Visit { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload