|
| 1 | +[](https://travis-ci.org/kreuzerk/ng-sortgrid) |
| 2 | +[](https://codecov.io/gh/kreuzerk/ng-sortgrid) |
| 3 | +[]() |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +Read the README or just simply check out our demo at: https://kreuzerk.github.io/ng-sortgrid/ |
| 10 | + |
| 11 | +- [Getting started](#getting-started) |
| 12 | + - [Download the module](#download-the-module) |
| 13 | + - [Apply the directive](#apply-the-directive) |
| 14 | + - [React on changes](#react-on-changes) |
| 15 | + |
| 16 | +# Getting started |
| 17 | +## Download the module |
| 18 | + |
| 19 | +``` |
| 20 | +npm i -s ng-sortgrid |
| 21 | +``` |
| 22 | + |
| 23 | +Import the ```NgsgModule``` in your ```AppModule```. |
| 24 | + |
| 25 | +``` |
| 26 | + ... |
| 27 | + imports: [BrowserModule, NgsgModule], |
| 28 | + ... |
| 29 | +``` |
| 30 | + |
| 31 | +## Apply the directive |
| 32 | +Loop over your elements with *ngFor. 🛎️ the items needs to be an array. Alternate you can also use the async pipe to pass in your items. |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +Apply the ngSortgridItem directive |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +## React on changes |
| 41 | +In most cases you are interested in the new sort order. Often you want to store them in local storage or even send them to the backend. To do so the following two steps are needed in addition to the "Getting started" step. |
| 42 | + |
| 43 | +Pass your items to the directive via the ngSortGridItems input. |
| 44 | + |
| 45 | + |
| 46 | +React on the 'sorted' output events |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +## Group sortgrids |
| 51 | +In case you have more than one sortgriditem on the page you need to group the sortgriditems to avoid dropping drags from one group in another group. |
| 52 | +Pass in a unique name to the ngSortGridGroup input |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +## Use the async pipe |
| 57 | +You can also use the async pipe to display items |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +# Style your items on different events |
| 62 | +The ng-sortgrid adds different classes on different events to your items. You can either use those classes to style the appereance |
| 63 | +of your items on certain events or you can include the build in CSS from the ng-sortgrid library. |
| 64 | + |
| 65 | +## Integrate the build in CSS |
| 66 | +To integrate the built in Stylesheet just import in in your angular.json. |
| 67 | + |
| 68 | +``` |
| 69 | + "styles": [ |
| 70 | + "node_modules/ng-sortgrid/dist/lib/ngsg.css", |
| 71 | + ], |
| 72 | +``` |
| 73 | + |
| 74 | +Alternative you can provide custom styles for the different classes listed bellow |
| 75 | + |
| 76 | +| Class | Description | |
| 77 | +|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------| |
| 78 | +| ng-sg-placeholder | This class is added to the placeholder item which previews where the item is inserted | |
| 79 | +| ng-sg-dropped | This class is added as soon after you drop an item. The class will be on the item for 500 milliseconds before it gets removed | |
| 80 | +| ng-sg-selected | This class is added when you press the CMD or the Ctrl Key and Click on an item. It indicates which items are selected for the multi drag&drop | |
0 commit comments