locked
CRM 2011 Custom Subgrid Development RRS feed

  • Question

  • Hey Guys,

    What are the options available to us using javascript to specify the number of rows to present in javascript? Using the CRM Form editing tool you can specify the number of rows to present, but this is static. Is there any way programatically specify the number of rows based on the records that would be brought back (This is assuming the result count is less than 20)?


    Thanks in Advance

    Friday, August 16, 2013 12:45 AM

Answers

  • If you actually set the subgrid to 'auto expand' it will only occupy as many rows as it needs. You can still set the page limit to 20, or even 250 and it will just add a scroll bar once it fills the entire height of the page.

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    • Marked as answer by Bill Blancett Friday, August 16, 2013 3:34 PM
    Friday, August 16, 2013 7:04 AM

All replies

  • If you actually set the subgrid to 'auto expand' it will only occupy as many rows as it needs. You can still set the page limit to 20, or even 250 and it will just add a scroll bar once it fills the entire height of the page.

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    • Marked as answer by Bill Blancett Friday, August 16, 2013 3:34 PM
    Friday, August 16, 2013 7:04 AM
  • You can use the following code to filter a grid:-

    function UpdateSubGrid(){ 
        var leadGrid = document.getElementById("Condensate");  
        //If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding   
        //Included extra null check as a rollup 5 fix
        if (leadGrid ==null || leadGrid.readyState != "complete") {
            //The subgrid hasn't loaded, wait 1 second and then try again     
            setTimeout('UpdateSubGrid()', 1000);     
            return; 
        }  //Update the fetchXML that will be used by the grid.
        var oPack = Xrm.Page.getAttribute("new_condensateid").getValue()[0].id;
        var fetchXml= '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="new_pack"><attribute name="new_packid" /><attribute name="new_name" /><attribute name="createdon" /><attribute name="new_totalprice" /><attribute name="new_quantity" /><attribute name="new_listprice" /><order attribute="new_name" descending="false" /><filter type="and"><condition attribute="new_productpackid" operator="eq" value="'+oPack+'"/></filter><link-entity name="product" from="productid" to="new_productid" visible="false" link-type="outer" alias="a_7696afcf6bf0e2119c5178e3b508aaa1"><attribute name="productnumber" /></link-entity></entity></fetch>';
       // alert(fetchXml);
       
        leadGrid.control.SetParameter("fetchXml", fetchXml); 
        //Force the subgrid to refresh 
        leadGrid.control.Refresh();
    onChangeofCondensate() ;
    }
    function onChangeofCondensate() {
        if (Xrm.Page.getAttribute("new_condensateid").getValue() != null) {
            Xrm.Page.ui.tabs.get(2).sections.get(5).setVisible(true);
        }
        else {
             Xrm.Page.ui.tabs.get(2).sections.get(5).setVisible(false);
            
        }
    }


    Regards Faisal

    Friday, August 16, 2013 8:51 AM