0

I got a custom grid table in ui components

I got a column ("Cifra Corrente" -> current_amount) that IS NOT an attribute in my db-schema, it's calculated in my dataProvider getData(), I calculate it with a join, I can order it but I can't apply filters (Something went wrong with processing current custom view and filters have been reset to its original state. Please edit filters then click apply.). How can I use filters on this column?

Ui\Component\Listing\DataProviders\Objective\Grid:

public function getData()
{
    $this->getCollection()->getSelect()
        ->joinInner(
            [
                'objective' => $this->getCollection()->getTable('vendor_module_objective')
            ],
            "(objective.supplier_id = main_table.supplier_id)",
            [
                'objective_id' => 'entity_id',
                'import' => 'import',
                'start_date' => 'start_date',
                'end_date' => 'end_date',
                'start_amount' => 'start_amount',
                'target_amount' => 'target_amount',
            ]
        )
        ->joinInner(
            [
                'supplier' => $this->getCollection()->getTable('vendor_module_supplier')
            ],
            "(supplier.entity_id = main_table.supplier_id)",
            [
                'business_name' => 'business_name'
            ]
        )
        ->where('objective.start_date <= main_table.date')
        ->where('objective.end_date >= main_table.date')
        ->columns(['current_amount' => new \Zend_Db_Expr('SUM(amount)')])
        ->group('objective.entity_id');

Column in my form.xml

<column name="current_amount">
        <settings>
            <filter>textRange</filter>
            <dataType>price</dataType>
            <label translate="true">Cifra Corrente</label>
        </settings>
    </column>

I want to use this

enter image description here

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.