title: Displaying mvc object in Dojo DGrid
body: <p>Hi All looking for some help. I am new to using Dojo this is my first try
  I hava a data call that returns a list of objects. I cant get it to display more than one record at a time. The grid header renders but no data if I try to load more than one object.  Here is the Code. I am not sure what I am doing wrong.  Been working on this for a week now. someone please help. What am I doing wrong.</p>
  
  <p>data looks like this 
  the raw view looks like this </p>
  
  <p>"{\"FSC\":\"195\",\"IINSGM\":\"12345\",\"MMAC\":\"GG\",\"ISMASTER\":\"12345\",\"ItemName\":\"ECU(801A)\",\"ALC\":\"W\",\"WING\":\" SCMW\",\"GROUP\":\"SCMG\",\"SQUADRON\":\"SCMS\",\"DIR\":\"LM\",\"DIV\":\"Y\"</p>
  
  <p>there is actually I think ten lines like this there will be more later.</p>
  
  <pre><code>  &lt;script&gt;
  
  
  //var data = [];
  
  @* @foreach(System.Web.Mvc.JsonResult s in Model)
  {
      @:data.push('@Html.Raw(Json.Encode(s))');
  }*@
  
  @*getData();
  function getData() {
      var actionResult = '@Url.Action("Report","Alc")';
      $.getJSON(actionResult, loadData);
  }
  function loadData(responce) {
      if (responce != null) {
          for (var i = 0 ; i &lt; responce.length; i++) {
              data.push(responce[i]);
  
          }
      }
  }*@
  
  @*var model = '@Html.Raw(Json.Encode(Model))'.;
  var data = [];
  $.each(model.Data, function () {
      data.push($(this));
  });*@ // all above this point i tried and they didn't work
  
  var data = '@Html.Raw(Json.Encode(Model))';// this works with one record
  var myStore, dataStore, grid;
  myStore = JSON.parse(data).Data;
  
  require([
  'dstore/Memory',
  'dgrid/OnDemandGrid',
  'dojo/_base/declare',
  'dgrid/ColumnSet'
  ], function (Memory, OnDemandGrid, declare, ColumnSet)
  {
  
      var CustomGrid = declare([OnDemandGrid, ColumnSet]);
      var data = [
    {
      FSC: myStore.FSC,
      IINSGM: myStore.IINSGM,
      ISMaster: myStore.ISMASTER,
      ItemName: myStore.ItemName,
      MMAC: myStore.MMAC,
      ALC: myStore.ALC,
      WING: myStore.WING,
      GROUP: myStore.GROUP,
      SQUADRON: myStore.SQUADRON,
      DIR: myStore.DIR,
      DIV: myStore.DIV,
      IMS: myStore.IMS,
      ES: myStore.ES,
      PMSBUYER: myStore.PMSBUYER,
      PMSSELLER: myStore.PMSSELLER,
      ERRC: myStore.ERRC,
      ITEMCAT: myStore.ITEMCAT,
      ALT: myStore.ALT,
      PLT: myStore.PLT,
      SMC: myStore.SMC,
      ItmDefDispossalCode: myStore.ItmDefDispossalCode,
      ItmDefDispossalLevel: myStore.ItmDefDispossalLevel,
      ItmDefDispossalSRCCo: myStore.ItmDefDispossalSRCCode,
      DEMIC: myStore.DEMIC,
      ItemActivityCD: myStore.ItemActivityCD,
      SecurityCode: myStore.SecurityCode,
      BP: myStore.BP,
      NextHigherAssembly: myStore.NextHigherAssembly,
      UnitPrice: myStore.UnitPrice,
      FUP: myStore.FUP,
      WTURC: myStore.WTURC,
      BuyQtyCy: myStore.BuyQtyCy,
      BuyDollars: myStore.BuyDollars,
      ORWM: myStore.ORWM,
      BuyQtyAY: myStore.BuyQtyAY,
      BuyDollarsAY: myStore.BuyDollarsAY,
      BuyQTR: myStore.BuyQTR,
      BuyDollars: myStore.BuyDollars,
      RepairQtyCy: myStore.RepairQtyCy,
      RepairDollCy: myStore.RepairDollCy,
      RepairQtyAy: myStore.RepairQtyAy,
      RepairDollAy: myStore.RepairDollAy,
      RepairQty: myStore.RepairQty,
      RepairDoll: myStore.RepairDoll,
      ExcessQty: myStore.ExcessQty,
      ExcessDollar: myStore.ExcessDollar,
      TermQty: myStore.TermQty,
      TermDollar: myStore.TermDollar,
      NetAsset: myStore.NetAsset,
      Rate: myStore.Rate,
      PastConds: myStore.PastConds,
      futureConds: myStore.futureConds,
      CondsPerYr: myStore.CondsPerYr,
      YrsOfSupply: myStore.YrsOfSupply,
      SummaryType: myStore.SummaryType
  }
  ];
      grid = new CustomGrid({
      collection: new Memory({ data: data }),
  
      columnSets: [
              [
                  [
                      { label: "FSC", field: "FSC", width: "34px" },
                      { label: "SGM NIIN", field: "IINSGM", width: "74px" },
                      { label: "I &amp; S Master", field: "ISMaster", width: "95px" },
                      { label: "Item Name", field: "ItemName", width: "90px" }
  ]
  ], [
                  [
                      { label: "MMAC", field: "MMAC", width: "55px" },
                      { label: "ALC", field: "ALC", width: "40px" },
                      { label: "Wing", field: "WING", width: "50px" },
                      { label: "Group", field: "GROUP", width: "50px" },
                      { label: "Squadron", field: "SQUADRON", width: "75px" },
                      { label: "DIR", field: "DIR", width: "30px" },
                      { label: "DIV", field: "DIV", width: "30px" },
                      { label: "IMS", field: "IMS", width: "30px" },
                      { label: "ES", field: "ES", width: "30px" },
                      { label: "PMS Buyer", field: "PMSBUYER", width: "85px" },
                      { label: "PMS Seller", field: "PMSSELLER", width: "85px" },
                      { label: "ERRC", field: "ERRC", width: "50px" },
                      { label: "ItemCat", field: "ITEMCAT", width: "60px" },
                      { label: "ALT", field: "ALT", width: "40px" },
                      { label: "PLT", field: "PLT", width: "40px" },
                      { label: "SMC", field: "SMC", width: "40px" },
                      { label: "Item Def Disposal Code", field: "ItmDefDispossalCode", width: "140px" },
                      { label: "Item Def Disposal Level", field: "ItmDefDispossalLevel", width: "140px" },
                      { label: "Item Def Disposal SRC Code", field: "ItmDefDispossalSRCCo", width: "140px" },
                      { label: "DEMIL", field: "DEMIC", width: "50px" },
                      { label: "Item Activity Cd", field: "ItemActivityCD", width: "120px" },
                      { label: "Security Code", field: "SecurityCode", width: "120px" },
                      { label: "BP", field: "BP", width: "30px" },
                      { label: "Next Higher Assembly", field: "NextHigherAssembly", width: "120px" },
                      { label: "Unit Price", field: "UnitPrice", width: "75px" },
                      { label: "FUP", field: "FUP", width: "40px" },
                      { label: "WT URC", field: "WTURC", width: "70px" },
                      { label: "Buy Qty(CY)", field: "BuyQtyCy", width: "100px" },
                      { label: "Buy Dollars(CY)", field: "BuyDollars", width: "125px" },
                      { label: "OWRM", field: "ORWM", width: "55px" },
                      { label: "Buy Qty(AY)", field: "BuyQtyAY", width: "100px" },
                      { label: "Buy Dollars(AY)", field: "BuyDollarsAY", width: "125px" },
                      { label: "Buy Qty", field: "BuyQTR", width: "90px" },
                      { label: "Buy Dollars", field: "BuyDollars", width: "90px" },
                      { label: "Repair Qty(CY)", field: "RepairQtyCy", width: "120px" },
                      { label: "Repair Dollars(CY)", field: "RepairDollCy", width: "145px" },
                      { label: "Repair Qty(AY)", field: "RepairQtyAy", width: "120px" },
                      { label: "Repair Dollars(AY)", field: "RepairDollAy", width: "145px" },
                      { label: "Repair Qty", field: "RepairQty", width: "90px" },
                      { label: "Repair Dollars", field: "RepairDoll", width: "120px" },
                      { label: "Excess Qty", field: "ExcessQty", width: "90px" },
                      { label: "Excess Dollars", field: "ExcessDollar", width: "120px" },
                      { label: "Term Qty", field: "TermQty", width: "80px" },
                      { label: "Term Dollars", field: "TermDollar", width: "100px" },
                      { label: "Net Assets", field: "NetAsset", width: "100px" },
                      { label: "Rate", field: "Rate", width: "50px" },
                      { label: "Past Conds", field: "PastConds", width: "20px" },
                      { label: "Future Conds", field: "futureConds", width: "20px" },
                      { label: "Conds per Year", field: "CondsPerYr", width: "20px" },
                      { label: "Years of Supply", field: "YrsOfSupply", width: "20px" },
                      { label: "Summary Type", field: "SummaryType", width: "20px" }
          ]
      ]
  ],
      loadingMessage: 'Loading data...',
      noDataMessage: 'No results found.',
  }, 'grid');
      grid.startup();
  
  
  });
  </code></pre>
  
  <p></p>
  
  <pre><code>    &lt;div id="grid" class="dgrid dgrid-grid ui-widget grid dgrid-autoheight"    style="height: 400px; width: auto; margin: 10px;"&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>here is the controller</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Report(FilterModelBig model)
      {
          //run the report program 
          AlcReportBuilder250 report = new AlcReportBuilder250();
          var data = report.BuildReport(model);
  
          //return View(Json(data, JsonRequestBehavior.AllowGet)); this is what I need it does not work
  
          return View(Json(data[0], JsonRequestBehavior.AllowGet)); // this works
      }
  </code></pre>
  
  <p>I have 10 records to display it could be up to a 1000 later  any advice would be great !</p>