0

How to create Admin Grid Without Form in magento 2 . I don't need form i Just Want Grid with my content I am referring to Cache or Re indexing kind of Grid is this possible to achieve that I tried with rendering but its not done Can you please help me on this to achieve that feature

Screenshot for reference below: enter image description here

Magento\SampleForm\view\adminhtml\ui_component\sampleform_form.xml

<listing  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd">
  <dataSource name="sampleform_form_data_source">
        <argument name="dataProvider" xsi:type="configurableObject">
            <argument name="class" xsi:type="string">Magento\SampleForm\Model\DataProvider</argument>
            <argument name="name" xsi:type="string">sampleform_form_data_source</argument>
            <argument name="primaryFieldName" xsi:type="string">entity_id</argument>
            <argument name="requestFieldName" xsi:type="string">id</argument>
        </argument>
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
            </item>
        </argument>
    </dataSource> 


 <columns name="mysampleform">
    <column name="entity_id">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">text</item>
                <item name="editor" xsi:type="array">
                    <item name="editorType" xsi:type="string">text</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
                <item name="label" xsi:type="string" translate="true">entity_id</item>
            </item>
        </argument>
    </column>

     <column name="color">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">text</item>
                <item name="editor" xsi:type="array">
                    <item name="editorType" xsi:type="string">text</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
                <item name="label" xsi:type="string" translate="true">color</item>
            </item>
        </argument>
    </column>

    <column name="title">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">text</item>
                <item name="editor" xsi:type="array">
                    <item name="editorType" xsi:type="string">text</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
                <item name="label" xsi:type="string" translate="true">title</item>
            </item>
        </argument>
    </column>

     </columns>

 </listing>

Magento\SampleForm\view\adminhtml\layout\sampleform_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left"  xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <head>
        <title>
            Test Content By Ankit
        </title>
        <css src="Magento_SampleForm::css/color-select.css"/>
    </head>
    <update handle="styles"/>
    <body>
        <referenceContainer name="content">
            <uiComponent name="sampleform_form"/>
        </referenceContainer>
    </body>
</page>

1 Answer 1

0

In Magento 1 as in Magento 2, grids and forms are two different things.
You can create a grid without a form and a form without a grid. The two are often linked but this is not an obligation.

To create a grid in Magento 2 you have to use the listing UI Component.
Here you can find more informations about them :

If you want an example on how to create one you can take a look at CMS pages in Magento_Cms module.
You have to create a ui_component : magento/module-cms/view/adminhtml/ui_component/cms_page_listing.xml

Here you can find a complete explanation https://magento.stackexchange.com/a/97891/33619

16
  • thankf for reply but i dont want grid like below Screen shot i want only cache or reindex grid screencast.com/t/2dXVT8mlIQE Commented Jan 24, 2017 at 17:19
  • Yes that is the same answer, you have to use ui_component anyway. The only thing that will change is the DataProvider class. Commented Jan 24, 2017 at 17:22
  • I added screen what i need i updated my question please check Commented Jan 24, 2017 at 17:22
  • In the ui_component declaration you don't have to add buttons, search bar, etc you can do a simple ui_component with only column and DataProvider class. But you definitly have to use ui components ;) Commented Jan 24, 2017 at 17:24
  • i tried this sample module github.com/magento/magento2-samples/blob/master/… but i am getting error Fatal error: Method Magento\Ui\TemplateEngine\Xhtml\Result::__toString() must not throw an exception, caught Error: Call to a member function addFieldToFilter() on null in E:\Personal\Project\xampp\htdocs\magento2\vendor\magento\module-ui\Component\Wrapper\UiComponent.php on line 0 Commented Jan 24, 2017 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.