title: How to show items in admin grid by parent id magento 2
body: <p>Try to get items in admin grid by parent id.
  For example I have url "/admin/navmenu/grid/addrow/id/1/", and want to get all items from database where <code>parent_id = 1</code>.</p>
  
  <p>Some ideas to filter them in DataProvider using <code>getData()</code> function, or there are better ways to solve this?</p>
  
  <p><strong>This is my ui component xml</strong>
      </p>
  
  <pre><code>&lt;listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Ui/etc/ui_configuration.xsd"&gt;
      &lt;argument name="data" xsi:type="array"&gt;
          &lt;item name="js_config" xsi:type="array"&gt;
              &lt;item name="provider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list_data_source&lt;/item&gt;
              &lt;item name="deps" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list_data_source&lt;/item&gt;
          &lt;/item&gt;
          &lt;item name="spinner" xsi:type="string"&gt;grid_records_columns&lt;/item&gt;
          &lt;item name="buttons" xsi:type="array"&gt;
              &lt;item name="add" xsi:type="array"&gt;
                  &lt;item name="name" xsi:type="string"&gt;add&lt;/item&gt;
                  &lt;item name="label" xsi:type="string" translate="true"&gt;Add Menu Item&lt;/item&gt;
                  &lt;item name="class" xsi:type="string"&gt;primary&lt;/item&gt;
                  &lt;item name="url" xsi:type="string"&gt;*/*/addrow&lt;/item&gt;
              &lt;/item&gt;
          &lt;/item&gt;
      &lt;/argument&gt;
      &lt;dataSource name="navmenu_items_grid_sub_list_data_source"&gt;
          &lt;argument name="dataProvider" xsi:type="configurableObject"&gt;
              &lt;!-- &lt;argument name="class" xsi:type="string"&gt;Test\Navmenu\Ui\Component\Listing\Grid\Column\ItemsGridSubListDataProvider&lt;/argument&gt; --&gt;
              &lt;argument name="class" xsi:type="string"&gt;Test\Navmenu\Ui\DataProvider\ItemsGridSubListDataProvider&lt;/argument&gt;
              &lt;argument name="name" xsi:type="string"&gt;navmenu_items_grid_sub_list_data_source&lt;/argument&gt;
              &lt;argument name="primaryFieldName" xsi:type="string"&gt;entity_id&lt;/argument&gt;
              &lt;argument name="requestFieldName" xsi:type="string"&gt;id&lt;/argument&gt;
              &lt;argument name="data" xsi:type="array"&gt;
                  &lt;item name="config" xsi:type="array"&gt;
                      &lt;item name="update_url" xsi:type="url" path="mui/index/render"/&gt;
                  &lt;/item&gt;
              &lt;/argument&gt;
          &lt;/argument&gt;
          &lt;argument name="data" xsi:type="array"&gt;
              &lt;item name="js_config" xsi:type="array"&gt;
                  &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/provider&lt;/item&gt;
              &lt;/item&gt;
          &lt;/argument&gt;
      &lt;/dataSource&gt;
      &lt;container name="listing_top"&gt;
          &lt;argument name="data" xsi:type="array"&gt;
              &lt;item name="config" xsi:type="array"&gt;
                  &lt;item name="template" xsi:type="string"&gt;ui/grid/toolbar&lt;/item&gt;
                  &lt;item name="stickyTmpl" xsi:type="string"&gt;ui/grid/sticky/toolbar&lt;/item&gt;
              &lt;/item&gt;
          &lt;/argument&gt;
          &lt;bookmark name="bookmarks"/&gt;
          &lt;columnsControls name="columns_controls"/&gt;
          &lt;filters name="listing_filters"&gt;
              &lt;argument name="data" xsi:type="array"&gt;
                  &lt;item name="config" xsi:type="array"&gt;
                      &lt;item name="columnsProvider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.grid_records_columns&lt;/item&gt;
                      &lt;item name="storageConfig" xsi:type="array"&gt;
                          &lt;item name="provider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.listing_top.bookmarks&lt;/item&gt;
                          &lt;item name="namespace" xsi:type="string"&gt;current.filters&lt;/item&gt;
                      &lt;/item&gt;
                      &lt;item name="templates" xsi:type="array"&gt;
                          &lt;item name="filters" xsi:type="array"&gt;
                              &lt;item name="select" xsi:type="array"&gt;
                                  &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/form/element/ui-select&lt;/item&gt;
                                  &lt;item name="template" xsi:type="string"&gt;ui/grid/filters/elements/ui-select&lt;/item&gt;
                              &lt;/item&gt;
                          &lt;/item&gt;
                      &lt;/item&gt;
                      &lt;item name="childDefaults" xsi:type="array"&gt;
                          &lt;item name="provider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.listing_top.listing_filters&lt;/item&gt;
                          &lt;item name="imports" xsi:type="array"&gt;
                              &lt;item name="visible" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.grid_records_columns.${ $.index }:visible&lt;/item&gt;
                          &lt;/item&gt;
                      &lt;/item&gt;
                  &lt;/item&gt;
                  &lt;item name="observers" xsi:type="array"&gt;
                      &lt;item name="column" xsi:type="string"&gt;column&lt;/item&gt;
                  &lt;/item&gt;
              &lt;/argument&gt;
          &lt;/filters&gt;
          &lt;massaction name="listing_massaction"&gt;
              &lt;argument name="data" xsi:type="array"&gt;
                  &lt;item name="config" xsi:type="array"&gt;
                      &lt;item name="selectProvider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.grid_records_columns.ids&lt;/item&gt;
                      &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/tree-massactions&lt;/item&gt;
                      &lt;item name="indexField" xsi:type="string"&gt;id&lt;/item&gt;
                  &lt;/item&gt;
              &lt;/argument&gt;
              &lt;!-- Mass actions which you want to add in your grid--&gt;
              &lt;action name="delete"&gt;
                  &lt;argument name="data" xsi:type="array"&gt;
                      &lt;item name="config" xsi:type="array"&gt;
                          &lt;item name="type" xsi:type="string"&gt;delete&lt;/item&gt;
                          &lt;item name="label" xsi:type="string" translate="true"&gt;Delete&lt;/item&gt;
                          &lt;item name="url" xsi:type="url" path="navmenu/grid/massdelete"/&gt;
                          &lt;item name="confirm" xsi:type="array"&gt;
                              &lt;item name="title" xsi:type="string" translate="true"&gt;Delete&lt;/item&gt;
                              &lt;item name="message" xsi:type="string" translate="true"&gt;Do you want to delete selected row record?&lt;/item&gt;
                          &lt;/item&gt;
                      &lt;/item&gt;
                  &lt;/argument&gt;
              &lt;/action&gt;
          &lt;/massaction&gt;
          &lt;paging name="listing_paging"&gt;
              &lt;argument name="data" xsi:type="array"&gt;
                  &lt;item name="config" xsi:type="array"&gt;
                      &lt;item name="storageConfig" xsi:type="array"&gt;
                          &lt;item name="provider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.listing_top.bookmarks&lt;/item&gt;
                          &lt;item name="namespace" xsi:type="string"&gt;current.paging&lt;/item&gt;
                      &lt;/item&gt;
                      &lt;item name="selectProvider" xsi:type="string"&gt;navmenu_items_grid_sub_list.navmenu_items_grid_sub_list.grid_records_columns.ids&lt;/item&gt;
                  &lt;/item&gt;
              &lt;/argument&gt;
          &lt;/paging&gt;
      &lt;/container&gt;
      &lt;columns name="grid_records_columns"&gt;
          &lt;selectionsColumn name="ids"&gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="indexField" xsi:type="string"&gt;entity_id&lt;/item&gt;
                     &lt;item name="sorting" xsi:type="string"&gt;desc&lt;/item&gt;
                     &lt;item name="sortOrder" xsi:type="number"&gt;0&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/selectionsColumn&gt;
         &lt;column name="title"&gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="filter" xsi:type="string"&gt;textRange&lt;/item&gt;
                     &lt;item name="label" xsi:type="string" translate="true"&gt;Title&lt;/item&gt;
                     &lt;item name="sortOrder" xsi:type="number"&gt;1&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/column&gt;
         &lt;column name="static_url" &gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="filter" xsi:type="string"&gt;false&lt;/item&gt;
                     &lt;item name="label" xsi:type="string" translate="true"&gt;Static Url&lt;/item&gt;
                     &lt;item name="sortOrder" xsi:type="number"&gt;1&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/column&gt;
         &lt;column name="is_active" &gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="options" xsi:type="object"&gt;Test\Navmenu\Model\Status&lt;/item&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="filter" xsi:type="string"&gt;select&lt;/item&gt;
                     &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/columns/select&lt;/item&gt;
                     &lt;item name="dataType" xsi:type="string"&gt;select&lt;/item&gt;
                     &lt;item name="label" xsi:type="string" translate="true"&gt;Is Active&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/column&gt;
         &lt;!-- &lt;column name="publish_date" class="Magento\Ui\Component\Listing\Columns\Date" &gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="filter" xsi:type="string"&gt;dateRange&lt;/item&gt;
                     &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/columns/date&lt;/item&gt;
                     &lt;item name="dataType" xsi:type="string"&gt;date&lt;/item&gt;
                     &lt;item name="label" xsi:type="string" translate="true"&gt;Publish Date&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/column&gt; --&gt;
         &lt;column name="update_time" class="Magento\Ui\Component\Listing\Columns\Date" &gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="filter" xsi:type="string"&gt;dateRange&lt;/item&gt;
                     &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/columns/date&lt;/item&gt;
                     &lt;item name="dataType" xsi:type="string"&gt;date&lt;/item&gt;
                     &lt;item name="label" xsi:type="string" translate="true"&gt;Update Time&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/column&gt;
         &lt;column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date" &gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="filter" xsi:type="string"&gt;dateRange&lt;/item&gt;
                     &lt;item name="component" xsi:type="string"&gt;Magento_Ui/js/grid/columns/date&lt;/item&gt;
                     &lt;item name="dataType" xsi:type="string"&gt;date&lt;/item&gt;
                     &lt;item name="label" xsi:type="string" translate="true"&gt;Created At&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/column&gt;
         &lt;!-- Add Action with each row of grid and for this we will create a class Action --&gt;
         &lt;actionsColumn name="actions" class="Test\Navmenu\Ui\Component\Listing\Grid\Column\Action"&gt;
             &lt;argument name="data" xsi:type="array"&gt;
                 &lt;item name="config" xsi:type="array"&gt;
                     &lt;item name="resizeEnabled" xsi:type="boolean"&gt;false&lt;/item&gt;
                     &lt;item name="resizeDefaultWidth" xsi:type="string"&gt;107&lt;/item&gt;
                     &lt;item name="indexField" xsi:type="string"&gt;id&lt;/item&gt;
                 &lt;/item&gt;
             &lt;/argument&gt;
         &lt;/actionsColumn&gt;
      &lt;/columns&gt;
  &lt;/listing&gt;
  </code></pre>
  
  <p><strong>This is DataProvider</strong></p>
  
  <pre><code>&lt;?php
  
  namespace Test\Navmenu\Ui\DataProvider;
  
  
  class ItemsGridSubListDataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider
  {
  
      public function getData()
      {
          $parent_id = $this-&gt;request-&gt;getParam('id');
          $data = parent::getData();
          foreach()
          return [];
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/aVTA6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aVTA6.png" alt="enter image description here"></a></p>