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
How to extend grid with Javascript extensions #240
Conversation
@matks my first ps tutorial 😄 |
|
# Extend a grid with Javascript extensions. Preparation | ||
Javascript grid extensions supplements grid functionality and enhances user experience. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javascript grid extensions supplements grid functionality and enhances user experience. | |
Javascript grid extensions supplement grid behavior and enhance user experience. |
# Extend a grid with Javascript extensions. Preparation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preparation
?
BulkActionCheckboxExtension which enables interactive selection of bulk actions and so on. | ||
|
||
In this tutorial we use an example of taxes grid to show how to use extensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this tutorial we use an example of taxes grid to show how to use extensions. | |
In this tutorial we use a grid that display taxes items to show how to use extensions. |
To start we will need to have a plain grid already created in php side | ||
(you can find more docs about grid here https://devdocs.prestashop.com/1.7/development/components/grid). | ||
After following some guides we should be ready. Our grid looks like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After following some guides we should be ready. Our grid looks like this: | |
After following the Grid documentation directions you should now have a fully working php grid. The twig template should look like this: |
``` | ||
{{< figure src="../../img/taxes_grid.png" title="Taxes grid example" >}} | ||
Although the grid looks complete, none of the actions are working yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the grid looks complete, none of the actions are working yet. | |
Although the grid looks complete, none of the actions are working yet because the javascript behavior is not enabled yet. |
{{< figure src="../../img/taxes_grid.png" title="Taxes grid example" >}} | ||
Although the grid looks complete, none of the actions are working yet. | ||
To get started, create javascript file for your page and add entry in your webpack config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 3 steps here, write it as a list then explain each step 😉
For our example, index.js will land in `admin-dev/themes/new-theme/js/pages/tax/index.js`, then | ||
we add an entry point in `admin-dev/themes/new-theme/.webpack/common.js`. | ||
Don't forget to add your compiled file path to html script tag (same as with pagination bundle above). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to show the code 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it's kinda from another topic. Like 'how to add javascript to html' 😄
# Adding extensions | ||
|
||
Lets open our index.js and start by importing Grid component from `admin-dev/themes/new-theme/js/components/grid/grid.js` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First show the code snippet, then explain what it does 😉
|
||
``` | ||
import Grid from '../../components/grid/grid'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add JS comments to explain sections
}); | ||
``` | ||
That's it, the last thing to do is to run the compiler and extensions should be working. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to guide the reader to the "compiler" section with npm commands
@matks addressed your comments |
Thank you @zuk3975 |
Added tutorial that explains how to use Javascript extensions for grid.