Magento 2 : Invalid block type while creating custom grid in backend The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Setup version for module 'Sample_CustomController' is not specifiedI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Not able to add/update magento2 category post upgrade from 1.9 to 2.1.0Trying to uninstall moduleHow to solve Front controller reached 100 router match iterations in magento2Magento 2 Front controller reached 100 router match iterations issueDeleted ShipperHQ module causing error in “All Customers” section of Magento 2“Area code is not set” in var/logwhen click on place order then paypal showing error in Magento2magento error logs Error log record number: 1173359093956

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

Is this wall load bearing? Blueprints and photos attached

Take groceries in checked luggage

Who or what is the being for whom Being is a question for Heidegger?

Is there a trick to getting spices to fix to nuts?

What is this lever in Argentinian toilets?

Does Parliament hold absolute power in the UK?

How did passengers keep warm on sail ships?

Simulating Exploding Dice

Semisimplicity of the category of coherent sheaves?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

How to stretch delimiters to envolve matrices inside of a kbordermatrix?

How should I replace vector<uint8_t>::const_iterator in an API?

What can I do if neighbor is blocking my solar panels intentionally?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

Am I ethically obligated to go into work on an off day if the reason is sudden?

Can smartphones with the same camera sensor have different image quality?

What is special about square numbers here?

How does ice melt when immersed in water?

Road tyres vs "Street" tyres for charity ride on MTB Tandem

How to pronounce 1ターン?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Movie about afterlife I think? Large towers with clothing and food?

How do you keep chess fun when your opponent constantly beats you?



Magento 2 : Invalid block type while creating custom grid in backend



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Setup version for module 'Sample_CustomController' is not specifiedI created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Not able to add/update magento2 category post upgrade from 1.9 to 2.1.0Trying to uninstall moduleHow to solve Front controller reached 100 router match iterations in magento2Magento 2 Front controller reached 100 router match iterations issueDeleted ShipperHQ module causing error in “All Customers” section of Magento 2“Area code is not set” in var/logwhen click on place order then paypal showing error in Magento2magento error logs Error log record number: 1173359093956



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I've been trying to create custom gird in magento 2.0.11 but it keep returning Invalid block type:



This error occurs while executing the file Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php in following code :



$this->setChild(
'grid',
$this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
);


But I have block TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid



Invalid block type: TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid
#0 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(237): MagentoFrameworkViewLayoutGeneratorBlock->getBlockInstance('Tomrain\Appcust...', Array)
#1 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(760): MagentoFrameworkViewLayoutGeneratorBlock->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
#2 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(743): MagentoFrameworkViewLayout->_createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
#3 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(349): MagentoFrameworkViewLayout->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
#4 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php(41): MagentoFrameworkViewLayoutInterceptor->createBlock('Tomrain\Appcust...', 'appcustomizer.g...')
#5 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Element/AbstractBlock.php(262): TomrainAppcustomizerBlockAdminhtmlClipartcategories->_prepareLayout()
#6 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(139): MagentoFrameworkViewElementAbstractBlock->setLayout(Object(MagentoFrameworkViewLayoutInterceptor))
#7 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/GeneratorPool.php(86): MagentoFrameworkViewLayoutGeneratorBlock->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
#8 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(327): MagentoFrameworkViewLayoutGeneratorPool->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
#9 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): MagentoFrameworkViewLayout->generateElements()
#10 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(129): MagentoFrameworkViewLayoutInterceptor->generateElements()
#11 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Page/Builder.php(55): MagentoFrameworkViewLayoutBuilder->generateLayoutBlocks()
#12 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(65): MagentoFrameworkViewPageBuilder->generateLayoutBlocks()
#13 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(244): MagentoFrameworkViewLayoutBuilder->build()
#14 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(859): MagentoFrameworkViewLayout->build()
#15 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): MagentoFrameworkViewLayout->getBlock('menu')
#16 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/Model/View/Result/Page.php(59): MagentoFrameworkViewLayoutInterceptor->getBlock('menu')
#17 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): MagentoBackendModelViewResultPage->setActiveMenu('Tomrain_Appcust...')
#18 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index.php(36): MagentoBackendModelViewResultPageInterceptor->setActiveMenu('Tomrain_Appcust...')
#19 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(25): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndex->execute()
#20 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Action.php(102): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->execute()
#21 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/AbstractAction.php(226): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#22 [internal function]: MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
#23 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#24 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callParent('dispatch', Array)
#25 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminAuthentica...')
#26 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
#27 [internal function]: MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#28 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#29 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'designLoader')
#30 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Plugin/Design.php(39): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
#31 [internal function]: MagentoFrameworkAppActionPluginDesign->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#32 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#33 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminMassaction...')
#34 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
#35 [internal function]: MagentoBackendAppActionPluginMassactionKey->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#36 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
#37 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(40): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callPlugins('dispatch', Array, Array)
#38 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/FrontController.php(55): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#39 [internal function]: MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
#40 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#41 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
#42 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Magento\Framewo...', 'dispatch', Object(MagentoFrameworkAppFrontControllerInterceptor), Array, 'install')
#43 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
#44 [internal function]: MagentoFrameworkModulePluginDbStatusValidator->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
#45 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
#46 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
#47 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Http.php(115): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
#48 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Bootstrap.php(258): MagentoFrameworkAppHttp->launch()
#49 /var/www/html/appcustomizer-tshirt-M2/index.php(42): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))


Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php



namespace TomrainAppcustomizerBlockAdminhtml;

class Clipartcategories extends MagentoBackendBlockWidgetContainer

/**
* @var string
*/
protected $_template = 'clipartcategories/entries.phtml';

/**
* @param MagentoBackendBlockWidgetContext $context
* @param array $data
*/
public function __construct(
MagentoBackendBlockWidgetContext $context,
array $data = []
)
parent::__construct($context, $data);


/**
* Prepare button and grid
*
* @return MagentoCatalogBlockAdminhtmlProduct
*/
protected function _prepareLayout()

$addButtonProps = [
'id' => 'add_new_entry_post',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);

$this->setChild(
'grid',
$this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
);
return parent::_prepareLayout();


/**
*
*
* @return array
*/
protected function _getAddButtonOptions()


$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];

return $splitButtonOptions;


/**
*
*
* @param string $type
* @return string
*/
protected function _getCreateUrl()

return $this->getUrl(
'appcustomizer/*/new'
);


/**
* Render grid
*
* @return string
*/
public function getGridHtml()

return $this->getChildHtml('grid');




Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories/Grid.php



namespace TomrainAppcustomizerBlockAdminhtmlClipartcategories;

class Grid extends MagentoBackendBlockWidgetGridExtended

/**
* @var MagentoFrameworkModuleManager
*/
protected $moduleManager;

/**
* @var TomrainAppcustomizerModelClipartcategoriesFactory
*/
protected $_clipartcategoriesFactory;

protected $_status;

/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoBackendHelperData $backendHelper
* @param TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory
* @param TomrainAppcustomizerModelStatus $status
* @param MagentoFrameworkModuleManager $moduleManager
* @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoBackendHelperData $backendHelper,
TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory,
TomrainAppcustomizerModelStatus $status,
MagentoFrameworkModuleManager $moduleManager,
array $data = []
)
$this->_clipartcategoriesFactory = $clipartcategoriesFactory;
$this->_status = $status;
$this->moduleManager = $moduleManager;
parent::__construct($context, $backendHelper, $data);


/**
* @return void
*/
protected function _construct()

parent::_construct();
$this->setId('postGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('post_filter');


/**
* @return $this
*/
protected function _prepareCollection()

$collection = $this->_clipartcategoriesFactory->create()->getCollection();
$this->setCollection($collection);

parent::_prepareCollection();
return $this;


/**
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareColumns()

$this->addColumn(
'id',
[
'header' => __('ID'),
'type' => 'number',
'index' => 'id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id',
'name'=>'id'
]
);

$this->addColumn(
'label',
[
'header' => __('Category'),
'index' => 'label',
'class' => 'xxx',
'name'=>'label'
]
);

$this->addColumn(
'parent_id',
[
'header' => __('Parent Category'),
'index' => 'parent_id',
'class' => 'xxx',
'name'=>'parent_id',
'options' => $this->_status->_getAttributeOptions()
]
);

$this->addColumn(
'image',
array(
'header' => __('Image'),
'index' => 'image',
'renderer' => 'TomrainAppcustomizerBlockAdminhtmlInquiryGridRendererClipartcategories',
)
);

$this->addColumn(
'status',
[
'header' => __('Active'),
'index' => 'status',
'type' => 'options',
'name'=>'status',
'options' => $this->_status->getOptionArray()
]
);


$this->addColumn(
'edit',
[
'header' => __('Edit'),
'type' => 'action',
'getter' => 'getId',
'actions' => [
[
'caption' => __('Edit'),
'url' => [
'base' => '*/*/edit'
],
'field' => 'id'
]
],
'filter' => false,
'sortable' => false,
'index' => 'stores',
'header_css_class' => 'col-action',
'column_css_class' => 'col-action'
]
);

$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block)
$this->setChild('grid.bottom.links', $block);


return parent::_prepareColumns();


/**
* @return $this
*/
protected function _prepareMassaction()


$this->setMassactionIdField('id');
$this->getMassactionBlock()->setTemplate('Tomrain_Appcustomizer::clipartcategories/grid/massaction_extended.phtml');
$this->getMassactionBlock()->setFormFieldName('label');

$this->getMassactionBlock()->addItem(
'delete',
[
'label' => __('Delete'),
'url' => $this->getUrl('appcustomizer/*/massDelete'),
'confirm' => __('Are you sure?')
]
);

$statuses = $this->_status->getOptionArray();

array_unshift($statuses, ['label' => '', 'value' => '']);
$this->getMassactionBlock()->addItem(
'status',
[
'label' => __('Change status'),
'url' => $this->getUrl('appcustomizer/*/massStatus', ['_current' => true]),
'additional' => [
'visibility' => [
'name' => 'status',
'type' => 'select',
'class' => 'required-entry',
'label' => __('Status'),
'values' => $statuses
]
]
]
);


return $this;


/**
* @return string
*/
public function getGridUrl()

return $this->getUrl('appcustomizer/*/grid', ['_current' => true]);


public function getRowUrl($row)

return $this->getUrl(
'appcustomizer/*/edit',
['id' => $row->getId()]
);











share|improve this question






























    0















    I've been trying to create custom gird in magento 2.0.11 but it keep returning Invalid block type:



    This error occurs while executing the file Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php in following code :



    $this->setChild(
    'grid',
    $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
    );


    But I have block TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid



    Invalid block type: TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid
    #0 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(237): MagentoFrameworkViewLayoutGeneratorBlock->getBlockInstance('Tomrain\Appcust...', Array)
    #1 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(760): MagentoFrameworkViewLayoutGeneratorBlock->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
    #2 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(743): MagentoFrameworkViewLayout->_createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
    #3 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(349): MagentoFrameworkViewLayout->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
    #4 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php(41): MagentoFrameworkViewLayoutInterceptor->createBlock('Tomrain\Appcust...', 'appcustomizer.g...')
    #5 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Element/AbstractBlock.php(262): TomrainAppcustomizerBlockAdminhtmlClipartcategories->_prepareLayout()
    #6 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(139): MagentoFrameworkViewElementAbstractBlock->setLayout(Object(MagentoFrameworkViewLayoutInterceptor))
    #7 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/GeneratorPool.php(86): MagentoFrameworkViewLayoutGeneratorBlock->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
    #8 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(327): MagentoFrameworkViewLayoutGeneratorPool->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
    #9 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): MagentoFrameworkViewLayout->generateElements()
    #10 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(129): MagentoFrameworkViewLayoutInterceptor->generateElements()
    #11 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Page/Builder.php(55): MagentoFrameworkViewLayoutBuilder->generateLayoutBlocks()
    #12 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(65): MagentoFrameworkViewPageBuilder->generateLayoutBlocks()
    #13 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(244): MagentoFrameworkViewLayoutBuilder->build()
    #14 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(859): MagentoFrameworkViewLayout->build()
    #15 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): MagentoFrameworkViewLayout->getBlock('menu')
    #16 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/Model/View/Result/Page.php(59): MagentoFrameworkViewLayoutInterceptor->getBlock('menu')
    #17 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): MagentoBackendModelViewResultPage->setActiveMenu('Tomrain_Appcust...')
    #18 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index.php(36): MagentoBackendModelViewResultPageInterceptor->setActiveMenu('Tomrain_Appcust...')
    #19 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(25): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndex->execute()
    #20 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Action.php(102): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->execute()
    #21 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/AbstractAction.php(226): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #22 [internal function]: MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #23 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
    #24 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callParent('dispatch', Array)
    #25 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminAuthentica...')
    #26 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
    #27 [internal function]: MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
    #28 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
    #29 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'designLoader')
    #30 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Plugin/Design.php(39): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
    #31 [internal function]: MagentoFrameworkAppActionPluginDesign->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
    #32 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
    #33 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminMassaction...')
    #34 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
    #35 [internal function]: MagentoBackendAppActionPluginMassactionKey->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
    #36 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
    #37 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(40): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callPlugins('dispatch', Array, Array)
    #38 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/FrontController.php(55): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #39 [internal function]: MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #40 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
    #41 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
    #42 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Magento\Framewo...', 'dispatch', Object(MagentoFrameworkAppFrontControllerInterceptor), Array, 'install')
    #43 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
    #44 [internal function]: MagentoFrameworkModulePluginDbStatusValidator->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
    #45 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
    #46 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
    #47 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Http.php(115): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
    #48 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Bootstrap.php(258): MagentoFrameworkAppHttp->launch()
    #49 /var/www/html/appcustomizer-tshirt-M2/index.php(42): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))


    Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php



    namespace TomrainAppcustomizerBlockAdminhtml;

    class Clipartcategories extends MagentoBackendBlockWidgetContainer

    /**
    * @var string
    */
    protected $_template = 'clipartcategories/entries.phtml';

    /**
    * @param MagentoBackendBlockWidgetContext $context
    * @param array $data
    */
    public function __construct(
    MagentoBackendBlockWidgetContext $context,
    array $data = []
    )
    parent::__construct($context, $data);


    /**
    * Prepare button and grid
    *
    * @return MagentoCatalogBlockAdminhtmlProduct
    */
    protected function _prepareLayout()

    $addButtonProps = [
    'id' => 'add_new_entry_post',
    'label' => __('Add New'),
    'class' => 'add',
    'button_class' => '',
    'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
    'options' => $this->_getAddButtonOptions(),
    ];
    $this->buttonList->add('add_new', $addButtonProps);

    $this->setChild(
    'grid',
    $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
    );
    return parent::_prepareLayout();


    /**
    *
    *
    * @return array
    */
    protected function _getAddButtonOptions()


    $splitButtonOptions[] = [
    'label' => __('Add New'),
    'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
    ];

    return $splitButtonOptions;


    /**
    *
    *
    * @param string $type
    * @return string
    */
    protected function _getCreateUrl()

    return $this->getUrl(
    'appcustomizer/*/new'
    );


    /**
    * Render grid
    *
    * @return string
    */
    public function getGridHtml()

    return $this->getChildHtml('grid');




    Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories/Grid.php



    namespace TomrainAppcustomizerBlockAdminhtmlClipartcategories;

    class Grid extends MagentoBackendBlockWidgetGridExtended

    /**
    * @var MagentoFrameworkModuleManager
    */
    protected $moduleManager;

    /**
    * @var TomrainAppcustomizerModelClipartcategoriesFactory
    */
    protected $_clipartcategoriesFactory;

    protected $_status;

    /**
    * @param MagentoBackendBlockTemplateContext $context
    * @param MagentoBackendHelperData $backendHelper
    * @param TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory
    * @param TomrainAppcustomizerModelStatus $status
    * @param MagentoFrameworkModuleManager $moduleManager
    * @param array $data
    *
    * @SuppressWarnings(PHPMD.ExcessiveParameterList)
    */
    public function __construct(
    MagentoBackendBlockTemplateContext $context,
    MagentoBackendHelperData $backendHelper,
    TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory,
    TomrainAppcustomizerModelStatus $status,
    MagentoFrameworkModuleManager $moduleManager,
    array $data = []
    )
    $this->_clipartcategoriesFactory = $clipartcategoriesFactory;
    $this->_status = $status;
    $this->moduleManager = $moduleManager;
    parent::__construct($context, $backendHelper, $data);


    /**
    * @return void
    */
    protected function _construct()

    parent::_construct();
    $this->setId('postGrid');
    $this->setDefaultSort('id');
    $this->setDefaultDir('DESC');
    $this->setSaveParametersInSession(true);
    $this->setUseAjax(true);
    $this->setVarNameFilter('post_filter');


    /**
    * @return $this
    */
    protected function _prepareCollection()

    $collection = $this->_clipartcategoriesFactory->create()->getCollection();
    $this->setCollection($collection);

    parent::_prepareCollection();
    return $this;


    /**
    * @return $this
    * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
    */
    protected function _prepareColumns()

    $this->addColumn(
    'id',
    [
    'header' => __('ID'),
    'type' => 'number',
    'index' => 'id',
    'header_css_class' => 'col-id',
    'column_css_class' => 'col-id',
    'name'=>'id'
    ]
    );

    $this->addColumn(
    'label',
    [
    'header' => __('Category'),
    'index' => 'label',
    'class' => 'xxx',
    'name'=>'label'
    ]
    );

    $this->addColumn(
    'parent_id',
    [
    'header' => __('Parent Category'),
    'index' => 'parent_id',
    'class' => 'xxx',
    'name'=>'parent_id',
    'options' => $this->_status->_getAttributeOptions()
    ]
    );

    $this->addColumn(
    'image',
    array(
    'header' => __('Image'),
    'index' => 'image',
    'renderer' => 'TomrainAppcustomizerBlockAdminhtmlInquiryGridRendererClipartcategories',
    )
    );

    $this->addColumn(
    'status',
    [
    'header' => __('Active'),
    'index' => 'status',
    'type' => 'options',
    'name'=>'status',
    'options' => $this->_status->getOptionArray()
    ]
    );


    $this->addColumn(
    'edit',
    [
    'header' => __('Edit'),
    'type' => 'action',
    'getter' => 'getId',
    'actions' => [
    [
    'caption' => __('Edit'),
    'url' => [
    'base' => '*/*/edit'
    ],
    'field' => 'id'
    ]
    ],
    'filter' => false,
    'sortable' => false,
    'index' => 'stores',
    'header_css_class' => 'col-action',
    'column_css_class' => 'col-action'
    ]
    );

    $block = $this->getLayout()->getBlock('grid.bottom.links');
    if ($block)
    $this->setChild('grid.bottom.links', $block);


    return parent::_prepareColumns();


    /**
    * @return $this
    */
    protected function _prepareMassaction()


    $this->setMassactionIdField('id');
    $this->getMassactionBlock()->setTemplate('Tomrain_Appcustomizer::clipartcategories/grid/massaction_extended.phtml');
    $this->getMassactionBlock()->setFormFieldName('label');

    $this->getMassactionBlock()->addItem(
    'delete',
    [
    'label' => __('Delete'),
    'url' => $this->getUrl('appcustomizer/*/massDelete'),
    'confirm' => __('Are you sure?')
    ]
    );

    $statuses = $this->_status->getOptionArray();

    array_unshift($statuses, ['label' => '', 'value' => '']);
    $this->getMassactionBlock()->addItem(
    'status',
    [
    'label' => __('Change status'),
    'url' => $this->getUrl('appcustomizer/*/massStatus', ['_current' => true]),
    'additional' => [
    'visibility' => [
    'name' => 'status',
    'type' => 'select',
    'class' => 'required-entry',
    'label' => __('Status'),
    'values' => $statuses
    ]
    ]
    ]
    );


    return $this;


    /**
    * @return string
    */
    public function getGridUrl()

    return $this->getUrl('appcustomizer/*/grid', ['_current' => true]);


    public function getRowUrl($row)

    return $this->getUrl(
    'appcustomizer/*/edit',
    ['id' => $row->getId()]
    );











    share|improve this question


























      0












      0








      0








      I've been trying to create custom gird in magento 2.0.11 but it keep returning Invalid block type:



      This error occurs while executing the file Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php in following code :



      $this->setChild(
      'grid',
      $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
      );


      But I have block TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid



      Invalid block type: TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid
      #0 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(237): MagentoFrameworkViewLayoutGeneratorBlock->getBlockInstance('Tomrain\Appcust...', Array)
      #1 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(760): MagentoFrameworkViewLayoutGeneratorBlock->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
      #2 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(743): MagentoFrameworkViewLayout->_createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
      #3 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(349): MagentoFrameworkViewLayout->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
      #4 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php(41): MagentoFrameworkViewLayoutInterceptor->createBlock('Tomrain\Appcust...', 'appcustomizer.g...')
      #5 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Element/AbstractBlock.php(262): TomrainAppcustomizerBlockAdminhtmlClipartcategories->_prepareLayout()
      #6 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(139): MagentoFrameworkViewElementAbstractBlock->setLayout(Object(MagentoFrameworkViewLayoutInterceptor))
      #7 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/GeneratorPool.php(86): MagentoFrameworkViewLayoutGeneratorBlock->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
      #8 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(327): MagentoFrameworkViewLayoutGeneratorPool->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
      #9 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): MagentoFrameworkViewLayout->generateElements()
      #10 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(129): MagentoFrameworkViewLayoutInterceptor->generateElements()
      #11 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Page/Builder.php(55): MagentoFrameworkViewLayoutBuilder->generateLayoutBlocks()
      #12 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(65): MagentoFrameworkViewPageBuilder->generateLayoutBlocks()
      #13 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(244): MagentoFrameworkViewLayoutBuilder->build()
      #14 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(859): MagentoFrameworkViewLayout->build()
      #15 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): MagentoFrameworkViewLayout->getBlock('menu')
      #16 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/Model/View/Result/Page.php(59): MagentoFrameworkViewLayoutInterceptor->getBlock('menu')
      #17 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): MagentoBackendModelViewResultPage->setActiveMenu('Tomrain_Appcust...')
      #18 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index.php(36): MagentoBackendModelViewResultPageInterceptor->setActiveMenu('Tomrain_Appcust...')
      #19 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(25): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndex->execute()
      #20 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Action.php(102): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->execute()
      #21 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/AbstractAction.php(226): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #22 [internal function]: MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #23 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
      #24 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callParent('dispatch', Array)
      #25 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminAuthentica...')
      #26 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
      #27 [internal function]: MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #28 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
      #29 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'designLoader')
      #30 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Plugin/Design.php(39): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
      #31 [internal function]: MagentoFrameworkAppActionPluginDesign->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #32 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
      #33 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminMassaction...')
      #34 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
      #35 [internal function]: MagentoBackendAppActionPluginMassactionKey->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #36 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
      #37 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(40): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callPlugins('dispatch', Array, Array)
      #38 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/FrontController.php(55): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #39 [internal function]: MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #40 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
      #41 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
      #42 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Magento\Framewo...', 'dispatch', Object(MagentoFrameworkAppFrontControllerInterceptor), Array, 'install')
      #43 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
      #44 [internal function]: MagentoFrameworkModulePluginDbStatusValidator->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #45 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
      #46 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
      #47 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Http.php(115): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #48 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Bootstrap.php(258): MagentoFrameworkAppHttp->launch()
      #49 /var/www/html/appcustomizer-tshirt-M2/index.php(42): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))


      Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php



      namespace TomrainAppcustomizerBlockAdminhtml;

      class Clipartcategories extends MagentoBackendBlockWidgetContainer

      /**
      * @var string
      */
      protected $_template = 'clipartcategories/entries.phtml';

      /**
      * @param MagentoBackendBlockWidgetContext $context
      * @param array $data
      */
      public function __construct(
      MagentoBackendBlockWidgetContext $context,
      array $data = []
      )
      parent::__construct($context, $data);


      /**
      * Prepare button and grid
      *
      * @return MagentoCatalogBlockAdminhtmlProduct
      */
      protected function _prepareLayout()

      $addButtonProps = [
      'id' => 'add_new_entry_post',
      'label' => __('Add New'),
      'class' => 'add',
      'button_class' => '',
      'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
      'options' => $this->_getAddButtonOptions(),
      ];
      $this->buttonList->add('add_new', $addButtonProps);

      $this->setChild(
      'grid',
      $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
      );
      return parent::_prepareLayout();


      /**
      *
      *
      * @return array
      */
      protected function _getAddButtonOptions()


      $splitButtonOptions[] = [
      'label' => __('Add New'),
      'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
      ];

      return $splitButtonOptions;


      /**
      *
      *
      * @param string $type
      * @return string
      */
      protected function _getCreateUrl()

      return $this->getUrl(
      'appcustomizer/*/new'
      );


      /**
      * Render grid
      *
      * @return string
      */
      public function getGridHtml()

      return $this->getChildHtml('grid');




      Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories/Grid.php



      namespace TomrainAppcustomizerBlockAdminhtmlClipartcategories;

      class Grid extends MagentoBackendBlockWidgetGridExtended

      /**
      * @var MagentoFrameworkModuleManager
      */
      protected $moduleManager;

      /**
      * @var TomrainAppcustomizerModelClipartcategoriesFactory
      */
      protected $_clipartcategoriesFactory;

      protected $_status;

      /**
      * @param MagentoBackendBlockTemplateContext $context
      * @param MagentoBackendHelperData $backendHelper
      * @param TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory
      * @param TomrainAppcustomizerModelStatus $status
      * @param MagentoFrameworkModuleManager $moduleManager
      * @param array $data
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
      public function __construct(
      MagentoBackendBlockTemplateContext $context,
      MagentoBackendHelperData $backendHelper,
      TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory,
      TomrainAppcustomizerModelStatus $status,
      MagentoFrameworkModuleManager $moduleManager,
      array $data = []
      )
      $this->_clipartcategoriesFactory = $clipartcategoriesFactory;
      $this->_status = $status;
      $this->moduleManager = $moduleManager;
      parent::__construct($context, $backendHelper, $data);


      /**
      * @return void
      */
      protected function _construct()

      parent::_construct();
      $this->setId('postGrid');
      $this->setDefaultSort('id');
      $this->setDefaultDir('DESC');
      $this->setSaveParametersInSession(true);
      $this->setUseAjax(true);
      $this->setVarNameFilter('post_filter');


      /**
      * @return $this
      */
      protected function _prepareCollection()

      $collection = $this->_clipartcategoriesFactory->create()->getCollection();
      $this->setCollection($collection);

      parent::_prepareCollection();
      return $this;


      /**
      * @return $this
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
      protected function _prepareColumns()

      $this->addColumn(
      'id',
      [
      'header' => __('ID'),
      'type' => 'number',
      'index' => 'id',
      'header_css_class' => 'col-id',
      'column_css_class' => 'col-id',
      'name'=>'id'
      ]
      );

      $this->addColumn(
      'label',
      [
      'header' => __('Category'),
      'index' => 'label',
      'class' => 'xxx',
      'name'=>'label'
      ]
      );

      $this->addColumn(
      'parent_id',
      [
      'header' => __('Parent Category'),
      'index' => 'parent_id',
      'class' => 'xxx',
      'name'=>'parent_id',
      'options' => $this->_status->_getAttributeOptions()
      ]
      );

      $this->addColumn(
      'image',
      array(
      'header' => __('Image'),
      'index' => 'image',
      'renderer' => 'TomrainAppcustomizerBlockAdminhtmlInquiryGridRendererClipartcategories',
      )
      );

      $this->addColumn(
      'status',
      [
      'header' => __('Active'),
      'index' => 'status',
      'type' => 'options',
      'name'=>'status',
      'options' => $this->_status->getOptionArray()
      ]
      );


      $this->addColumn(
      'edit',
      [
      'header' => __('Edit'),
      'type' => 'action',
      'getter' => 'getId',
      'actions' => [
      [
      'caption' => __('Edit'),
      'url' => [
      'base' => '*/*/edit'
      ],
      'field' => 'id'
      ]
      ],
      'filter' => false,
      'sortable' => false,
      'index' => 'stores',
      'header_css_class' => 'col-action',
      'column_css_class' => 'col-action'
      ]
      );

      $block = $this->getLayout()->getBlock('grid.bottom.links');
      if ($block)
      $this->setChild('grid.bottom.links', $block);


      return parent::_prepareColumns();


      /**
      * @return $this
      */
      protected function _prepareMassaction()


      $this->setMassactionIdField('id');
      $this->getMassactionBlock()->setTemplate('Tomrain_Appcustomizer::clipartcategories/grid/massaction_extended.phtml');
      $this->getMassactionBlock()->setFormFieldName('label');

      $this->getMassactionBlock()->addItem(
      'delete',
      [
      'label' => __('Delete'),
      'url' => $this->getUrl('appcustomizer/*/massDelete'),
      'confirm' => __('Are you sure?')
      ]
      );

      $statuses = $this->_status->getOptionArray();

      array_unshift($statuses, ['label' => '', 'value' => '']);
      $this->getMassactionBlock()->addItem(
      'status',
      [
      'label' => __('Change status'),
      'url' => $this->getUrl('appcustomizer/*/massStatus', ['_current' => true]),
      'additional' => [
      'visibility' => [
      'name' => 'status',
      'type' => 'select',
      'class' => 'required-entry',
      'label' => __('Status'),
      'values' => $statuses
      ]
      ]
      ]
      );


      return $this;


      /**
      * @return string
      */
      public function getGridUrl()

      return $this->getUrl('appcustomizer/*/grid', ['_current' => true]);


      public function getRowUrl($row)

      return $this->getUrl(
      'appcustomizer/*/edit',
      ['id' => $row->getId()]
      );











      share|improve this question
















      I've been trying to create custom gird in magento 2.0.11 but it keep returning Invalid block type:



      This error occurs while executing the file Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php in following code :



      $this->setChild(
      'grid',
      $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
      );


      But I have block TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid



      Invalid block type: TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid
      #0 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(237): MagentoFrameworkViewLayoutGeneratorBlock->getBlockInstance('Tomrain\Appcust...', Array)
      #1 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(760): MagentoFrameworkViewLayoutGeneratorBlock->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
      #2 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(743): MagentoFrameworkViewLayout->_createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
      #3 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(349): MagentoFrameworkViewLayout->createBlock('Tomrain\Appcust...', 'appcustomizer.g...', Array)
      #4 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php(41): MagentoFrameworkViewLayoutInterceptor->createBlock('Tomrain\Appcust...', 'appcustomizer.g...')
      #5 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Element/AbstractBlock.php(262): TomrainAppcustomizerBlockAdminhtmlClipartcategories->_prepareLayout()
      #6 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Generator/Block.php(139): MagentoFrameworkViewElementAbstractBlock->setLayout(Object(MagentoFrameworkViewLayoutInterceptor))
      #7 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/GeneratorPool.php(86): MagentoFrameworkViewLayoutGeneratorBlock->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
      #8 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(327): MagentoFrameworkViewLayoutGeneratorPool->process(Object(MagentoFrameworkViewLayoutReaderContext), Object(MagentoFrameworkViewLayoutGeneratorContext))
      #9 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): MagentoFrameworkViewLayout->generateElements()
      #10 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(129): MagentoFrameworkViewLayoutInterceptor->generateElements()
      #11 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Page/Builder.php(55): MagentoFrameworkViewLayoutBuilder->generateLayoutBlocks()
      #12 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout/Builder.php(65): MagentoFrameworkViewPageBuilder->generateLayoutBlocks()
      #13 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(244): MagentoFrameworkViewLayoutBuilder->build()
      #14 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/View/Layout.php(859): MagentoFrameworkViewLayout->build()
      #15 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): MagentoFrameworkViewLayout->getBlock('menu')
      #16 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/Model/View/Result/Page.php(59): MagentoFrameworkViewLayoutInterceptor->getBlock('menu')
      #17 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): MagentoBackendModelViewResultPage->setActiveMenu('Tomrain_Appcust...')
      #18 /var/www/html/appcustomizer-tshirt-M2/app/code/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index.php(36): MagentoBackendModelViewResultPageInterceptor->setActiveMenu('Tomrain_Appcust...')
      #19 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(25): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndex->execute()
      #20 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Action.php(102): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->execute()
      #21 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/AbstractAction.php(226): MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #22 [internal function]: MagentoBackendAppAbstractAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #23 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
      #24 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callParent('dispatch', Array)
      #25 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminAuthentica...')
      #26 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
      #27 [internal function]: MagentoBackendAppActionPluginAuthentication->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #28 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
      #29 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(63): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'designLoader')
      #30 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Action/Plugin/Design.php(39): MagentoFrameworkInterceptionChainChain->MagentoFrameworkInterceptionChainclosure(Object(MagentoFrameworkAppRequestHttp))
      #31 [internal function]: MagentoFrameworkAppActionPluginDesign->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #32 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
      #33 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Tomrain\Appcust...', 'dispatch', Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Array, 'adminMassaction...')
      #34 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
      #35 [internal function]: MagentoBackendAppActionPluginMassactionKey->aroundDispatch(Object(TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #36 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
      #37 /var/www/html/appcustomizer-tshirt-M2/var/generation/Tomrain/Appcustomizer/Controller/Adminhtml/Clipartcategories/Index/Interceptor.php(40): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->___callPlugins('dispatch', Array, Array)
      #38 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/FrontController.php(55): TomrainAppcustomizerControllerAdminhtmlClipartcategoriesIndexInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #39 [internal function]: MagentoFrameworkAppFrontController->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #40 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
      #41 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Chain/Chain.php(70): MagentoFrameworkAppFrontControllerInterceptor->___callParent('dispatch', Array)
      #42 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(138): MagentoFrameworkInterceptionChainChain->invokeNext('Magento\Framewo...', 'dispatch', Object(MagentoFrameworkAppFrontControllerInterceptor), Array, 'install')
      #43 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): MagentoFrameworkAppFrontControllerInterceptor->MagentoFrameworkInterceptionclosure(Object(MagentoFrameworkAppRequestHttp))
      #44 [internal function]: MagentoFrameworkModulePluginDbStatusValidator->aroundDispatch(Object(MagentoFrameworkAppFrontControllerInterceptor), Object(Closure), Object(MagentoFrameworkAppRequestHttp))
      #45 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/Interception/Interceptor.php(142): call_user_func_array(Array, Array)
      #46 /var/www/html/appcustomizer-tshirt-M2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): MagentoFrameworkAppFrontControllerInterceptor->___callPlugins('dispatch', Array, Array)
      #47 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Http.php(115): MagentoFrameworkAppFrontControllerInterceptor->dispatch(Object(MagentoFrameworkAppRequestHttp))
      #48 /var/www/html/appcustomizer-tshirt-M2/vendor/magento/framework/App/Bootstrap.php(258): MagentoFrameworkAppHttp->launch()
      #49 /var/www/html/appcustomizer-tshirt-M2/index.php(42): MagentoFrameworkAppBootstrap->run(Object(MagentoFrameworkAppHttp))


      Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories.php



      namespace TomrainAppcustomizerBlockAdminhtml;

      class Clipartcategories extends MagentoBackendBlockWidgetContainer

      /**
      * @var string
      */
      protected $_template = 'clipartcategories/entries.phtml';

      /**
      * @param MagentoBackendBlockWidgetContext $context
      * @param array $data
      */
      public function __construct(
      MagentoBackendBlockWidgetContext $context,
      array $data = []
      )
      parent::__construct($context, $data);


      /**
      * Prepare button and grid
      *
      * @return MagentoCatalogBlockAdminhtmlProduct
      */
      protected function _prepareLayout()

      $addButtonProps = [
      'id' => 'add_new_entry_post',
      'label' => __('Add New'),
      'class' => 'add',
      'button_class' => '',
      'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
      'options' => $this->_getAddButtonOptions(),
      ];
      $this->buttonList->add('add_new', $addButtonProps);

      $this->setChild(
      'grid',
      $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid')
      );
      return parent::_prepareLayout();


      /**
      *
      *
      * @return array
      */
      protected function _getAddButtonOptions()


      $splitButtonOptions[] = [
      'label' => __('Add New'),
      'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
      ];

      return $splitButtonOptions;


      /**
      *
      *
      * @param string $type
      * @return string
      */
      protected function _getCreateUrl()

      return $this->getUrl(
      'appcustomizer/*/new'
      );


      /**
      * Render grid
      *
      * @return string
      */
      public function getGridHtml()

      return $this->getChildHtml('grid');




      Tomrain/Appcustomizer/Block/Adminhtml/Clipartcategories/Grid.php



      namespace TomrainAppcustomizerBlockAdminhtmlClipartcategories;

      class Grid extends MagentoBackendBlockWidgetGridExtended

      /**
      * @var MagentoFrameworkModuleManager
      */
      protected $moduleManager;

      /**
      * @var TomrainAppcustomizerModelClipartcategoriesFactory
      */
      protected $_clipartcategoriesFactory;

      protected $_status;

      /**
      * @param MagentoBackendBlockTemplateContext $context
      * @param MagentoBackendHelperData $backendHelper
      * @param TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory
      * @param TomrainAppcustomizerModelStatus $status
      * @param MagentoFrameworkModuleManager $moduleManager
      * @param array $data
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
      public function __construct(
      MagentoBackendBlockTemplateContext $context,
      MagentoBackendHelperData $backendHelper,
      TomrainAppcustomizerModelClipartcategoriesFactory $clipartcategoriesFactory,
      TomrainAppcustomizerModelStatus $status,
      MagentoFrameworkModuleManager $moduleManager,
      array $data = []
      )
      $this->_clipartcategoriesFactory = $clipartcategoriesFactory;
      $this->_status = $status;
      $this->moduleManager = $moduleManager;
      parent::__construct($context, $backendHelper, $data);


      /**
      * @return void
      */
      protected function _construct()

      parent::_construct();
      $this->setId('postGrid');
      $this->setDefaultSort('id');
      $this->setDefaultDir('DESC');
      $this->setSaveParametersInSession(true);
      $this->setUseAjax(true);
      $this->setVarNameFilter('post_filter');


      /**
      * @return $this
      */
      protected function _prepareCollection()

      $collection = $this->_clipartcategoriesFactory->create()->getCollection();
      $this->setCollection($collection);

      parent::_prepareCollection();
      return $this;


      /**
      * @return $this
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
      protected function _prepareColumns()

      $this->addColumn(
      'id',
      [
      'header' => __('ID'),
      'type' => 'number',
      'index' => 'id',
      'header_css_class' => 'col-id',
      'column_css_class' => 'col-id',
      'name'=>'id'
      ]
      );

      $this->addColumn(
      'label',
      [
      'header' => __('Category'),
      'index' => 'label',
      'class' => 'xxx',
      'name'=>'label'
      ]
      );

      $this->addColumn(
      'parent_id',
      [
      'header' => __('Parent Category'),
      'index' => 'parent_id',
      'class' => 'xxx',
      'name'=>'parent_id',
      'options' => $this->_status->_getAttributeOptions()
      ]
      );

      $this->addColumn(
      'image',
      array(
      'header' => __('Image'),
      'index' => 'image',
      'renderer' => 'TomrainAppcustomizerBlockAdminhtmlInquiryGridRendererClipartcategories',
      )
      );

      $this->addColumn(
      'status',
      [
      'header' => __('Active'),
      'index' => 'status',
      'type' => 'options',
      'name'=>'status',
      'options' => $this->_status->getOptionArray()
      ]
      );


      $this->addColumn(
      'edit',
      [
      'header' => __('Edit'),
      'type' => 'action',
      'getter' => 'getId',
      'actions' => [
      [
      'caption' => __('Edit'),
      'url' => [
      'base' => '*/*/edit'
      ],
      'field' => 'id'
      ]
      ],
      'filter' => false,
      'sortable' => false,
      'index' => 'stores',
      'header_css_class' => 'col-action',
      'column_css_class' => 'col-action'
      ]
      );

      $block = $this->getLayout()->getBlock('grid.bottom.links');
      if ($block)
      $this->setChild('grid.bottom.links', $block);


      return parent::_prepareColumns();


      /**
      * @return $this
      */
      protected function _prepareMassaction()


      $this->setMassactionIdField('id');
      $this->getMassactionBlock()->setTemplate('Tomrain_Appcustomizer::clipartcategories/grid/massaction_extended.phtml');
      $this->getMassactionBlock()->setFormFieldName('label');

      $this->getMassactionBlock()->addItem(
      'delete',
      [
      'label' => __('Delete'),
      'url' => $this->getUrl('appcustomizer/*/massDelete'),
      'confirm' => __('Are you sure?')
      ]
      );

      $statuses = $this->_status->getOptionArray();

      array_unshift($statuses, ['label' => '', 'value' => '']);
      $this->getMassactionBlock()->addItem(
      'status',
      [
      'label' => __('Change status'),
      'url' => $this->getUrl('appcustomizer/*/massStatus', ['_current' => true]),
      'additional' => [
      'visibility' => [
      'name' => 'status',
      'type' => 'select',
      'class' => 'required-entry',
      'label' => __('Status'),
      'values' => $statuses
      ]
      ]
      ]
      );


      return $this;


      /**
      * @return string
      */
      public function getGridUrl()

      return $this->getUrl('appcustomizer/*/grid', ['_current' => true]);


      public function getRowUrl($row)

      return $this->getUrl(
      'appcustomizer/*/edit',
      ['id' => $row->getId()]
      );








      magento2 module admin custom-grid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 10 at 8:09









      Muhammad Anas

      607318




      607318










      asked May 10 '17 at 8:28









      user54031user54031

      1




      1




















          1 Answer
          1






          active

          oldest

          votes


















          0














          $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid');


          please check with above code.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f173764%2fmagento-2-invalid-block-type-while-creating-custom-grid-in-backend%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid');


            please check with above code.






            share|improve this answer





























              0














              $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid');


              please check with above code.






              share|improve this answer



























                0












                0








                0







                $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid');


                please check with above code.






                share|improve this answer















                $this->getLayout()->createBlock('TomrainAppcustomizerBlockAdminhtmlClipartcategoriesGrid', 'appcustomizer.grid');


                please check with above code.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 10 '17 at 8:35









                Rakesh Jesadiya

                30.3k1577124




                30.3k1577124










                answered May 10 '17 at 8:29









                Sunil PatelSunil Patel

                1,3781612




                1,3781612



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f173764%2fmagento-2-invalid-block-type-while-creating-custom-grid-in-backend%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Sum ergo cogito? 1 nng

                    三茅街道4182Guuntc Dn precexpngmageondP