locked
Filter Subgrid with Javascript - MS CRM 2013 RRS feed

  • Question

  • Hi,

    I want to filter a subgrid.

    My code :

    function FilterCasesSubgrid() { var CasesSubgrid =Xrm.Page.getControl("lots_associes"); if(CasesSubgrid==null){ setTimeout(function () { FilterCasesSubgrid(); }, 2000); //if the grid hasn’t loaded run this again when it has return; } var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+ "<entity name='new_lot'>"+ "<attribute name='new_name' />"+ "<attribute name='new_nomduprogramme' />"+ "<attribute name='new_villelookup' />"+ "<attribute name='new_loyertotal' />"+ "<order attribute='title' descending='false' />"+ "<filter type='and'>"+ "<condition attribute='new_name' operator='eq' value='004' />"+ "</filter>"+ "</entity>"+ "</fetch>";

    //Here i set the fetchxml directly to subgrid alert("1"); CasesSubgrid .control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid alert("2"); CasesSubgrid .control.Refresh(); //refresh the sub grid using the new fetch xml }

    with that I only have the first alert who says '1'. The last alert isn't displayed and the subgrid isn't modified.

    Do you have any idea?


    Wednesday, March 5, 2014 3:19 PM

All replies

  • Hi Cleine,

    Can you try using document.getElementById("lots_associes") instead? Also, did you try debugging and checking if Xrm.Page.getControl("lots_associes"); resolves?


    Admin QuikView Solution for CRM 2013


    • Edited by Anupam Bishui Wednesday, March 5, 2014 3:43 PM
    • Proposed as answer by Oskar Knobel Thursday, November 27, 2014 2:04 PM
    Wednesday, March 5, 2014 3:42 PM
  • Thank you very much for your reply.

    So, using document.getElementById("lots_associes") works fine.

    Thank you :)


    Wednesday, March 5, 2014 4:11 PM
  • Hi Celine,

    Glad I was able to help. :)


    Admin QuikView Solution for CRM 2013

    Wednesday, March 5, 2014 4:13 PM
  • Hi Celine, did you try this solution on Chrome? Did it work??
    Monday, December 1, 2014 5:19 PM
  • hey even i am facing the same issue..apparently this works only for Internet Explorer and not chrome or firefox...

    i even  tried with  Xrm.Page.ui.controls.get() and Xrm.Page.getControl() both didn't work for me

    //var SubscriptionGrid = Xrm.Page.ui.controls.get("Subscriptions");
    //var InvoiceGrid = Xrm.Page.getControl("Invoices");

    Does anybody have any suggestions for it.

    Wednesday, January 28, 2015 3:42 PM
  • Save the current record by filling all the mandatory fields. Then you will be able to see the records in sub grid.

    Hope it helps.


    Saturday, February 14, 2015 8:41 PM
  • Hi ,

    I shared it in my blog. Filtering subgrid


    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog

    Sunday, February 15, 2015 2:54 AM