Forums / Developing Portals / Invoke Subgrid dynamically

Invoke Subgrid dynamically

2 posts, 0 answered
  1. mani varma
    mani varma avatar
    8 posts
    21 Jul 2020
    05 Apr 2021
    Link to this post
    I need to invoke/create subgrid dynamically based on certain values on form. Can i create a new subgrid after all the widgets are loaded on the forms? If it is possible, please let me know how we can do that? I am aware of showing and hiding of subgrid. but not sure how to create them from frontend by Javascript.
  2. Josh
    Josh avatar
    47 posts
    01 Jun 2018
    03 May 2021 in reply to mani varma
    Link to this post

    Hello Mani,

    Currently there is no way to dynamically create TPC widgets using the JavaScript API, you will need to create and configure them using the Page or Form designer in the Sitefinity backend.

    Although, it is possible to filter a sub-grid or other form widgets based on values of fields within the form. You can do this using the Filters functionality. To add a filter based on the value of another widget, click Edit on the widget you are trying to filter in the TPC Form. Navigate to the Filters tab. Add a name to the filter, for example you can call it “FieldValue1” this will create a variable called @FieldValue1@. Under Filter Type select either Field Value or Optional Field Value depending on whether this filter should be required. For the value, select the field on which the value will be filtered and then click the + button to add the new filter. Now we have a variable called @FieldValue1@ which we can reference inside the FetchXML of the widget, it will automatically be replaced by the current value of the field. Within the TPC Fetch Builder of the widget, you can now add a FetchXML filter and reference the variable. Your fetch will look something like this:

    <fetch version="1.0" mapping="logical" output-format="xml-platform">
      <entity name="account">
        <attribute name="accountid" />
        <attribute name="name" />
        <order attribute="name" descending="false" />
        <filter type="and">
          <condition attribute="name" operator="eq" value="@FieldValue1@" />

    Please let me know if you have any other questions!



2 posts, 0 answered