Tips on resolving issues with cellclickable functionality in Angular with gridster2

VERSION: ^9.3.3

HTML

    <button (click)="toggleEditing()">{ editing ? 'cancel' : 'editing' }</button>
        <button>ADD</button>
        <gridster [options]="options">
            <gridster-item class="px-3 py-2" [item]="item" *ngFor="let item of dashboard">
         </gridster-item>
        </gridster>

TS

    editing = false;
    
    ngOnInit() {
     this.options = {
          gridType: GridType.Fit,
          margin: 0,
          outerMargin: null,
          outerMarginTop: null,
          outerMarginRight: null,
          outerMarginBottom: null,
          outerMarginLeft: null,
          useTransformPositioning: true,
          mobileBreakpoint: 640,
          keepFixedHeightInMobile: false,
          keepFixedWidthInMobile: false,
          scrollSensitivity: 10,
          scrollSpeed: 20,
          enableEmptyCellClick: this.editing,
          enableEmptyCellContextMenu: false,
          enableEmptyCellDrop: false,
          enableEmptyCellDrag: this.editing,
          emptyCellDragCallback: this.emptyCellClick.bind(this),
          enableOccupiedCellDrop: false,
          ignoreMarginInRow: false,
          draggable: {
            enabled: this.editing,
            stop: (event) => { this.setFlrLayout(event); }
          },
          resizable: {
            enabled: this.editing,
            stop: (event) => { this.setFlrLayout(event); }
          },
          swap: true,
          disablePushOnDrag: false,
          disablePushOnResize: false,
          pushDirections: { north: true, east: true, south: true, west: true },
          pushResizeItems: false,
          displayGrid: DisplayGrid.Always,
          disableWindowResize: false,
          disableWarnings: false,
          scrollToNewItems: false,
          itemInitCallback: ((item: GridsterItem, itemComponent: GridsterItemComponentInterface) => {
            window.dispatchEvent(new Event('resize'));  // to reisize respective charts 
          })
        };
    }
     toggleEditing() {
        this.editing = !this.editing;
        }


 

      ngOnChanges() {
     if (this.options && this.editing || this.options && !this.editing) {
          this.options['enableEmptyCellClick'] = this.editing;
        }
    }

     emptyCellClick(event: MouseEvent, item: GridsterItem): void {
    console.log(`test ${item}`);
    }

I am attempting to implement multi-selection in a grid. However, the click functionality is not working as expected. When I click on an empty cell, it does not trigger the console log in the dev tools.

For example, when I click on multiple empty cells for selection and then click "ADD", it should add those selected items accordingly.

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

TO

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

Answer №1

Within your TypeScript file, you are setting the value of options. Could you update the enableEmptyCellClick: false to enableEmptyCellClick: true?

Appreciate it @ABC

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

The number field is persisting with its content even after submitting, while the other fields successfully clear up

I am facing an issue where all fields clear up after submission except for the number field. I would appreciate any help on why this is happening and how to fix it. Thank you. Textfield number: const [number, setNumber] = useState(""); const han ...

What is the proper way to delete a callback from a promise object created by $q.defer() in AngularJS?

When working with AngularJS, the $q.defer() promise object has the ability to receive multiple notify callbacks without overwriting previous ones. var def = $q.defer(); def.promise.then(null, null, callback1); def.promise.then(null, null, callback2); If ...

What is the process for importing a JSON5 file in Typescript, just like you would with a regular JSON file?

I am looking to import a JSON5 file into a JavaScript object similar to how one can import a JSON file using [import config from '../config.json']. When hovering over, this message is displayed but it's clearly visible. Cannot find module & ...

Guide on how to add multiple options to a select element in HTML using prototype.js

What is the best way to add multiple options to a select tag in HTML using prototype js? Appreciate your help. ...

Having trouble utilizing HTML Canvas in the newest release of Angular and TypeScript

After extensive searching on the internet, I have not been able to find any working examples of using HTML canvas in Angular. It seems that changes in syntax in Typescript and Angular's newer versions have rendered all existing solutions obsolete. I ...

Increasing and decreasing values

I'd like to create two buttons for increasing and decreasing a value. For example, if the variable k is initially set to 4 and I press the decrement button, it should decrease from 4 to 3. This is what I attempted: var k = 1; function qtrFunction ...

How do I incorporate scrolling into Material-UI Tabs?

I am currently incorporating Material-ui Tablist into my AppBar component. However, I am facing an issue with the responsiveness of the tabs. When there are too many tabs, some of them become hidden on smaller screens. For more information on the componen ...

Identifying flex-wrap capabilities across different browsers

Currently, I am developing a project that involves implementing a responsive grid using the flex wrap property. However, since my project needs to support IE9 and older versions of Firefox (version 28 and below), I am in need of a way to determine their ...

Transforming button hues and passing a property to a subcomponent when clicked using vue.js

Just starting out with vue.js, I am attempting to create a component that functions in the following way: I have four buttons and when I click on one button, I want to change the colors of all four buttons and send a prop to a child component indicating w ...

How to Override Global CSS in a Freshly Created Angular Component

My CSS skills are a bit rusty and I need some assistance with a project I'm working on. The project includes multiple global CSS files that have properties defined for different tags, such as .btn. However, these global CSS files are causing conflicts ...

Incorporating the sx attribute into a personalized component

I am currently incorporating MUI v5 along with Gatsby Image in my project. To maintain consistency in my styling syntax throughout the application, I decided to include the sx prop in the GatsbyImage component. This is how I attempted it: <Box compon ...

Listening for Events from Child Components in Vue.js

I am struggling to figure out how to send an event from a child component to its parent in order to change the view. Although I have been able to create and emit the event, my template does not seem to be properly registering it. I am working with Single ...

What causes the Cassandra client driver to provide more detailed information compared to cqlsh?

I'm currently utilizing the datastax nodejs-driver to retrieve information about a keyspace from cassandra. const results = await client.execute( ` DESC KEYSPACE ${keyspace} ` ); The method client.execute provides a comprehensive object containin ...

Having trouble retrieving the attribute of an appended element in jQuery?

I am facing an issue where I am unable to retrieve the ID-attribute of an element that has been appended into my HTML. Each time I try, the result is always 'undefined'. How can I resolve this problem? jQuery('form#formular').append(&a ...

Renaming properties in an AngularJS model

After receiving the data in a structured format, my task is to present it on a graph using radio buttons. Each radio button should display the corresponding category name, but I actually need each button to show a custom label instead of the original categ ...

The socket context provider seems to be malfunctioning within the component

One day, I decided to create a new context file called socket.tsx: import React, { createContext } from "react"; import { io, Socket } from "socket.io-client"; const socket = io("http://localhost:3000", { reconnectionDela ...

ajax modal form editing

Encountered an issue with editing a form using modal ajax, where the edit form pops up but the data remains empty. The code snippet for my controller: public function edit() { $id=$this->uri->segment(3); $data=array( 'project' => $th ...

I am looking to create a counter in NextJS that will store its value in a database for persistent storage. How can

In my NextJS and ReactJS project, I am creating a like-counter feature that will keep track of the number of likes a user can give. The maximum limit for likes is set to 100. The count is stored in a FaunaDB. While I have successfully displayed the curren ...

Issue: The element '[object Object]' is of type 'object', which is not supported by NgFor. NgFor only works with Iterables like Arrays. - Problem encountered in an Ionic Project

I'm currently working on retrieving my user's username from Firebase Firestore Database using Ionic and AngularFire. I have implemented the valueChanges() method to obtain the observable and am trying to process it using an async pipe. However, u ...

Utilizing Javascript to load and parse data retrieved from an HTTP request

Within my application, a server with a rest interface is utilized to manage all database entries. Upon user login, the objective is to load and map all user data from database models to usable models. A key distinction between the two is that database mode ...