"Enhance your user experience with seamless drag and drop functionality for transferring items between

I am currently working on transferring items between a list and table using the drag-and-drop feature of PrimeNG. Both elements should be able to act as both drag sources and drop destinations.

My project is based on PrimeNG-9.0.0 and Angular 9.0.2

https://i.stack.imgur.com/pQpoM.png

I made some modifications based on the sample provided in the PrimeNG documentation:

 <div class="ui-g">
                    <div class="ui-g-12 ui-md-6 ui-g-nopad drag-column">
                        <ul style="margin:0;padding:0">
                            <li *ngFor="let car of availableCars" class="ui-helper-clearfix" pDraggable="cars"  pDroppable="Rcars"
                                (onDragStart)="dragStart($event,car)"   (onDrop)="drop($event)" (onDragEnd)="dragEnd($event)">
                                <div style="margin:8px 0 0 8px;float:left">{{car.vin}} - {{car.year}}</div>
                            </li>
                        </ul>
                    </div>

                <div class="ui-g-12 ui-md-6 drop-column" pDroppable="cars"  pDraggable="Rars"
                [ngClass]="{'ui-highlight-car':draggedCar}">
                <p-table [value]="selectedCars">
                    <ng-template pTemplate="header">
                        <tr>
                            <th>Vin</th>
                            <th>Year</th>
                            <th>Brand</th>
                            <th>Color</th>
                        </tr>
                    </ng-template>
                    <ng-template pTemplate="body" let-car>
                        <tr   (onDragStart)="dragStart($event,car)"  (onDrop)="drop($event)"
                        (onDragEnd)="dragEnd($event)">
                            <td>{{car.vin}}</td>
                            <td>{{car.year}}</td>
                            <td>{{car.brand}}</td>
                            <td>{{car.color}}</td>
                        </tr>
                    </ng-template>
                </p-table>
            </div>

If anyone has experience with this particular feature, any help would be greatly appreciated.

Answer №1

While I haven't explored primeNG, I do know that angular material offers a drag and drop feature.

To learn more about this functionality, you can check out drag and drop specifically the section titled Moving objects from one list to another

I believe it could be beneficial for your project

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why is the selected option not visible in the Angular 8 drop-down?

This is a commonly asked question, but my situation seems to be unique. None of the existing answers have provided a solution for my specific issue. Here is the code that I am working with: <form (ngSubmit)="getExceptions(f)" #f="ngForm"> ...

Struggling to grasp the process of incorporating OAuth into both a REST API and a Single Page Application

I am currently working on integrating my SPA, DjangoRestframework, and auth0. My understanding is that the user registration process, as well as logging in and out, are all handled by Angular. Here are some key questions I need assistance with: 1. Aft ...

Having trouble with ng build optimization error in Angular?

While developing a real-time chat application using Angular 13, I encountered an issue when trying to build the app for testing on my Node.js web server: ng build Every time I run this command, I receive an error in the console. Here is a screenshot of ...

Guide on incorporating file uploads in an Angular 6 project

I am currently working on creating a component where I have implemented a file upload function in a child component and am attempting to use that component's selector in another one. Here is my project structure: - upload : upload.component.html up ...

Encountering a problem with npm while trying to initialize a new Angular project causes

I encountered an issue while attempting to create a new Angular project using Git Bash console with the ng new command. I have successfully created projects in the past without any problems. For more information, please refer to the debug log here and th ...

How to utilize methods from different pages in Ionic 2

Looking to display the total number of items in an array on a card located on the home screen, but facing issues referencing methods outside of the typescript file they're written in. Trying to extract the array size method and utilize it in a differe ...

Angular compilation encounters errors

While following a tutorial from Angular University, I encountered an issue where running ng serve/npm start would fail. However, simply re-saving any file by adding or removing a blank space would result in successful compilation. You can view the screensh ...

Is there a way to make a mat-form-field read-only?

Is there a way to make mat-form-field read-only in Angular for a view that allows users to read but not edit the content? ...

What is the best way to organize information in a table based on the date

This is my data table https://i.stack.imgur.com/1DNlj.png in the displayed table, the registration dates are sorted with the oldest date at the top. However, I aim to have the newest data displayed first. Below is the code snippet I am using: this.dataSo ...

Managing the vertical dimensions of a div

I've created a unique set of visually appealing cards that house meaningful messages within an infinite scrolling feed. The intended functionality is for the complete message to be displayed upon clicking a "more" button, as the messages are typically ...

Utilizing Embedded Jetty for Angular URL rewriting

While deploying a WebSocket and an Angular application with Jetty, everything works fine during development. However, I am facing an issue in production where refreshing the frontend or entering a URL results in a 404 error from the server indicating that ...

Resetting the selected value in an Angular2 select element after the user makes a change

I have a dropdown menu which the user can select an option from. Initially it has a default value and when the user makes a new selection, I need to ask for confirmation by showing a message "are you sure?". If the answer is NO, then I should revert back t ...

Issue: The module 'MatChipList' (imported as 'i13$1') could not be located in '@angular/material/chips'

I am facing issues with upgrading my Angular project from version 5.x to 15.x due to the presence of alfresco-core dependencies. The errors I am encountering are causing obstacles in the process. Any assistance in resolving these problems would be greatly ...

Ways to change the CSS styling of the placeholder attribute within a textarea or input field tag

I am currently working on adjusting the font size of the text within the placeholder attribute of a textarea element. While I have been successful in achieving this using vanilla CSS, I have encountered difficulties when trying to implement the same concep ...

Is it possible for us to customize the angular material chip design to be in a rectangular shape

I recently implemented angular material chips as tags, but I was wondering if it's possible to customize the default circular design to a rectangle using CSS? ...

What is causing the issue where Multiple file selection does not work when using the multiple attribute

I am having issues with uploading multiple files on my website. I have created an input field with the attribute multiple, but for some reason, I am unable to select multiple files at once. app.html <input type="file" (change)="onChange($event)" req ...

What is the best way to establish a restriction on the number of items obtained from an RSS

I am receiving a feed from this specific link. My goal is to only retrieve the initial five items from the feed, but currently I am getting all of the items. Is there a way for me to specifically request only the first five items? Do I need to include an ...

Utilizing custom routing rules to fetch data from a local JSON file using http.get in Angular 2

Currently facing a challenge with Angular as a beginner, specifically when attempting to retrieve a local .json file using http.get. The issue seems to be related to my routing configuration, and I'm unsure how to resolve it. File Structure: api ...

Dissimilarities in behavior between Angular 2 AOT errors

While working on my angular 2 project with angular-cli, I am facing an issue. Locally, when I build it for production using ng build --prod --aot, there are no problems. However, when the project is built on the server, I encounter the following errors: . ...

A dynamic Angular component consisting of two distinct rows to be seamlessly integrated into an existing table

I'm currently working on a component called "template" that can consist of either two rows. @Component({ selector: '[my-row]', template: ` <tr> <td>first</td> <td>second</td> </tr> <t ...