Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show empty table / table head with fields when no results. #6791

Open
md-design-ch opened this issue Feb 5, 2025 · 0 comments
Open

Show empty table / table head with fields when no results. #6791

md-design-ch opened this issue Feb 5, 2025 · 0 comments

Comments

@md-design-ch
Copy link

md-design-ch commented Feb 5, 2025

the standard way the CRUD index page is displayed is - if there is no entries in DB there is no table, no table head, just empty page with 'No results found.'

I need to have table head with actual fields for the entity. Is there no easy way of controlling this?

if no then I could get the field names from here
$queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
where $fields contains all the fields which would be displayed, even if there are 0 entries.

then how do I pass it to crud/index.html.twig template?

   public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
    {
        // Build the original query builder (for MyEntity)
        $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters)
       
        $countQb = clone $queryBuilder;
        $countQb->select('COUNT(entity.id)');

        $count = (int) $countQb->getQuery()->getSingleScalarResult();

        if( 0=== $count) {

            // extract field names from $fields object and pass it to template somehow;

        }



        return $queryBuilder;
    }

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant