我试图在Prestashop 1.7中创建一个自定义网格,而不使用查询生成器。这有可能吗?例如,来自数组、集合或json数据。
这是Prestashop文档的教程。https://devdocs.prestashop.com/1.7/development/components/grid/
# Register ProductQueryBuilder
prestashop.core.grid.query.product_query_builder:
class: 'PrestaShop\PrestaShop\Core\Grid\Query\ProductQueryBuilder'
parent: 'prestashop.core.grid.abstract_query_builder'
arguments:
- "@=service('prestashop.adapter.legacy.context').getContext().language.id"
- "@=service('prestashop.adapter.legacy.context').getContext().shop.id"
public: true
# Configure our Grid Data factory to use the query builder that we registered above
prestashop.core.grid.data.factory.product_data_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\DoctrineGridDataFactory'
arguments:
- '@prestashop.core.grid.query.product_query_builder' # service id of our query builder
- '@prestashop.core.hook.dispatcher' # every doctrine query builder needs the hook dispatcher
- '@prestashop.core.grid.query.doctrine_query_parser' # parser to get the raw SQL query
- 'products' # this should match your grid id, in our case it's "products"
有什么想法可以用数组、集合或json数据来重构ProductQueryBuilder吗?谢谢。
发布于 2021-11-09 19:50:04
我在这种情况下使用了DataTable。
您可以从模板文件中生成的表中使用DataTable。这是让它工作的最快方法,但是如果您有大量的数据,它可能会消耗一些内存。
正式的DataTable文档是goog的一个开端:https://datatables.net/examples/data_sources/dom.html
您也可以使用AJAX中的DataTable来动态地执行它,但是您必须自己处理安全性和会话过期问题。
https://datatables.net/examples/ajax/
这些视频可能会给您一些设置DataTable和AJAX后端的想法。注意第二个视频中的安全细节。
https://stackoverflow.com/questions/69190739
复制相似问题