Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

getGrid().getRows() always returns 0 CRM 2016 on-premise

$
0
0

Hi,

Anyone knows if there's a problem with the subgrid implementation in crm 2016? This is the code I'm using but I never get any records from the grid even though a reference to the grid is returned. 

SetProductGridOnLoad: function () {

    var productGridControl = Xrm.Page.getControl("subgrid_products");

    productGridControl.addOnLoad(FBCrm.Lead.SetProductGridTimer);
  },

  SetProductGridTimer: function() {

    setTimeout(FBCrm.Lead.CalculateLeadProductsTotal, 2000);
  },

  /*
  * Re-Calculates the total when a new product is added to the
  * Lead products grid
  */
  CalculateLeadProductsTotal: function () {

    var productGrid = Xrm.Page.getControl("subgrid_products").getGrid();
    var productRows = productGrid.getRows(); // this always returns 0
    var total = 0;

    productRows.forEach(function (attribute, index) {

      var rowEntity = attribute.getData().getEntity();
      var listPrice = rowEntity.getAttributes().get("price");

      total += listPrice;

    });
    Xrm.Page.getAttribute("cust_totalprice").setValue(total);
    Xrm.Page.getAttribute("cust_totalprice").setSubmitMode("always");
  },

Thanks

Tony



Tony


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>