Angular UI Grid: Transferring rows between dual grids

Recently, I decided to give angular-ui-grid a try (http://ui-grid.info/) and attempted to implement a feature that involves moving rows between two different grids. I found a solution for this on the kendo grid here:

http://jsfiddle.net/OnaBai/2qXKy/
.

However, as a beginner in JavaScript, I struggled to replicate this functionality in angular-ui-grid. I am facing challenges in assigning selected rows from grid1 to grid2 and then removing them from grid1.

If anyone already has a working solution for this problem, I would greatly appreciate your help.

Thank you in advance.

UPDATE: I have also tried to create a quick but unsuccessful jsfiddle implementation here:

http://jsfiddle.net/LimoJoe/n9h7xmw3/4/

Answer №1

Check out this JSBin link that demonstrates how you can handle it using two controllers and a service. While it uses ngGrid, the concept should still be applicable to ui.grid in your case.

It seems like the issue might be related to how you are configuring the gridOptions. In your provided example, I didn't see where you defined the '`selectedItems' property within the gridOptions:

Here's the updated code snippet:

 this.gridOptions = {
     data: 't2.items',
     /** NG Grid approach
      selectedItems: [] 
     */
     /** UI Grid approach */
     enableRowSelection: true,
     enableSelectAll: true,
     multiSelect: true,
     onRegisterApi: function(gridApi) {
         $scope.gridApi = gridApi;
         gridApi.selection.on.rowSelectionChanged($scope, function(rows) {
             angular.copy(gridApi.selection.getSelectedRows(), ctl.selectedItems);
         });
      }
 };

Update:

In response to your feedback, I've created a modified version based on this plunkr fork of the referenced article which represents an enhanced iteration of the original resource. Hopefully, this will serve as a helpful starting point for you.

To transition from the mentioned article to ui-grid, remember that upgrading both Angular and ui-grid versions is essential.


Update:

I made some adjustments to your initial JsBin, and here is the revised version - new version. It now reflects an upgraded rendition of my original JsBin. We should be good now!

Answer №2

Here is the ultimate fix available on JSBin. It includes a newly implemented callback function named

gridApi.selection.on.rowSelectionChangedBatch
, allowing users to utilize the Select All button for automatic updates to the selected list.

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

Learn how to use Django HTML to transmit radio option selections through AJAX and dynamically load a form

How can I pass the value selected from a radio button to an ajax URL? I have a radio button for selecting either download or upload. CODE: <form id="listofiles" action="" class="post-form" role=form method="post">{% csrf_token %} Select: Downl ...

Prevent the routing on page reload in AngularJS

My route provider setup looks like this: app.config(function ($routeProvider, $locationProvider){ $locationProvider.hashPrefix(''); $routeProvider .when('/', { templateUrl: 'login.html', controller: 'loginCtrl&a ...

Custom AngularJS directive for validating date input forms

My current project involves an Angular 1.5.3 app. This is the task at hand: I have a user form with two date input fields. I need to implement custom validation on the form so that if the "expiry date" is greater than the "effective date", an error messa ...

What is the best way to limit the number of days that can be selected in v-calendar range for vue.js?

I am exploring the use of vuejs vcalendar range, and I am looking for a way to restrict the number of days that a user can select. Is there an option like "maxDays" available in vcalendar? I attempted to create a method where if the selected date range exc ...

Executing a Databind function using the keypress method in jQuery

On my simple page, I have a repeater being populated by a C# databind method. The page includes a search textbox that performs real-time searching as you type. This functionality is achieved by utilizing the rowfilter in the databind method to filter the r ...

Leverage Angularjs ng-repeat to organize array data within a specific framework

I have an array of data that I need help turning into a table using AngularJS ng-repeat. Can anyone assist with this task? var data=[ {status:"open",year:2014,value:100.00}, {status:"open",year:2015,value:200.00}, ...

How to utilize a Boolean return value in React Class component following a promise fetch operation

Hello, I have a question about a class I am working on in React. When I call Auth.isAuthenticated() from another component, it always returns false, even though the server is returning a 200 response which should set this.authenticated to true. How can I ...

Invoke a function in Angular when the value of a textarea is altered using JavaScript

Currently, I am working with angular and need to trigger my function codeInputChanged() each time the content of a textarea is modified either manually or programmatically using JavaScript. This is how my HTML for the textarea appears: <textarea class ...

Is it possible to render the v-for value dynamically?

I have a dynamic component and I'm trying to iterate through different objects from it. However, my current code isn't working as intended. Can someone please guide me on how to make the activeQuestion value in v-for dynamic? Thank you for your a ...

Ways to display an SVG spinner prior to a substantial UI refresh

I am currently facing an issue with updating 10 apexcharts bar charts simultaneously in a Vue app. When this process occurs, it takes approximately one second to load completely, and during that time, I would like to display an svg spinner. However, the co ...

The event bus in Vue.js is failing to emit events and send data to the component

Trying out the Vue event bus for the first time to pass data to child components from the main vue instance. However, despite my testing, I can't seem to retrieve the data inside my components. I believe the code is correct, but I'm uncertain. Is ...

Incorporate create-react-app with Express

Issue - I am encountering a problem where I do not receive any response from Postman when trying to access localhost:9000. Instead of getting the expected user JSON data back, I am seeing the following output: <body> <noscript>You need to ...

Is there a way to determine if a sound is actively being played?

My current challenge involves implementing automated tests for the <audio> tag to ensure it is playing. For testing, I am utilizing the standard angular test suite with karma and protractor. "devDependencies": { "karma": "~0.10", "protracto ...

I'm having trouble getting my .click method to work with the <div id=menuButton>. Can anyone help me figure out why this is happening?

Here is the HTML code I created for a dropdown menu. Initially, in the CSS file, the menu is set to display: none; <!doctype html> <html> <head> <title>DropDown Menu</title> <link rel="stylesheet" href="normalize ...

Unique content on a web page when it is loaded with HTML

Is there a way to dynamically load various content (such as <img> and <a>) into divs every time a page is loaded? I've seen websites with dynamic or rotating banners that display different content either at set intervals or when the page ...

Looking for a JavaScript or jQuery library that can automatically handle input direction?

Seeking a jQuery library for bidirectionality handling. Google offers one in the closure library, but it seems excessive to include the entire library just for bidirectional input support (unless you suggest otherwise) The Google closure library contains ...

The value being passed as a parameter is a number, which cannot be assigned to a parameter expecting a Date type

I'm currently in the process of testing a function by passing a date as a parameter, but I seem to be encountering an issue that I can't quite figure out. When structured like this, it throws an error stating "Argument of type 'number' ...

What methods can I use to identify when a browser autofills a saved password during a web login process?

My website has a feature that activates the login button when a user enters their username and password. However, an issue arises when the browser autofills this information, as the login button does not get enabled in such cases. Is there a way to use J ...

Retrieving data from the state in a React Component

As I am still learning about reactjs, I have come across the difference between React.createclass and React.component. In React.createclass, you can easily access an input value or any state value using code like this: change: function(e) { this.set ...

Deactivating a button using Jquery or Javascript after another button has been clicked

I'm looking for a way to disable one of two buttons when the other one has been clicked. Is there a more elegant solution that can be achieved using a single function and without inline JavaScript? Here is the HTML code: <button type="submit" id= ...