PHP code example of module-toolkit / table-manager

1. Go to this page and download the library: Download module-toolkit/table-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

module-toolkit / table-manager example snippets



namespace Vendor\Module;

use ModuleToolkit\TableManager\TableManager\TableManagerInterface;

class CustomModel
{
    public function __construct(
        protected TableManagerInterface $tableManager
    ){}
    
    public function getItems() {
        $tableRequest = $this->tableManager->getTableRequest();
        $tableRequest->setValue('test', 'value');
        $tableRequest->setValue('column_key', 'value');
        $tableRequest->setValue('column_key2', 'value2');
        
        $tableRequest->setSortOrder('column_key2', 'DESC');
        $tableRequest->setSortOrder('column_key1', 'ASC');
        
        $tableRequest->setGroup('column_key3');
        
        $result = $this->tableManager->getItems($tableRequest);
    }
    
    public function createItem() {
        $tableRequest = $this->tableManager->getTableRequest();
        $tableRequest->setValue('test', 'value');
        
        $wheelFitmentManager->createItem($tableRequest, $this->getFakeWheelItem());
    }
    
     public function updateItem() {
        $tableRequest = $this->tableManager->getTableRequest();
        $tableRequest->setValue('test', 'value');
        $entityId = 4;
        
        $wheelFitmentManager->createItem($tableRequest, $this->getFakeWheelItem(), $entityId, 'entity_id');
    }
    
}

 \ModuleToolkit\TableManager\TableManager\TableManager::findMatchingRecords(TableRequest $request, array $columns) 
.phtml
        <?= $block->getChildHtml('custom.grid');