Angular-Slickgrid: Some filters may not display on the header row

After thorough investigation and experimentation, I was able to identify both the issue and a suitable solution:

The problem stemmed from our dataset's usage of numeric IDs (e.g. 1,2,3,...). Within the code, there was an error where the grid misinterpreted columns and their corresponding IDs: When accessing the column ID using grid.getHeaderRowColumn(col.id) and populating it with col.id, a different ID would display compared to the actual col.id! Additionally, not all columns were being recognized, leading to issues with setting filters as intended. By converting the IDs to strings ('id1', 'id2', 'id3', ...), the problem was successfully resolved!

It remains uncertain whether this anomaly is a bug or related to dynamic columns behavior. Nevertheless, employing string IDs alleviated the issue for the time being. Many thanks to @ghiscoding for providing assistance.

Regarding my initial query:

I encountered an unusual dilemma during the construction of my slickgrid:

Despite specifying filter input boxes for all columns in the header row through column definitions, not all columns displayed these boxes upon grid creation.

Furthermore, adding or removing columns seemed to trigger the appearance or disappearance of filter boxes seemingly at random, albeit without any alterations to the defined columns. This erratic behavior persisted even when utilizing the same set of columns - creating inconsistencies each time.

In instances involving plain slickgrid, manual intervention sufficed to address this discrepancy by setting filters individually. However, transitioning to angular-slickgrid posed a new challenge -- how could I replicate this action within this framework?

Any insights or suggestions would be greatly appreciated.

For reference, I am currently utilizing angular-slickgrid version 2.15.4.

EDIT

The following excerpts showcase my dynamic gridOptions and ColumnDefinitions:

columnDefinitions: {
    0: {id: 6, …}
    1: {id: 2, …}
    2: {
        id: 4
        fieldtype: "string"
        name: "deliveryaddressadditionalline"
        json_translate_property: null
        field: "deliveryaddressadditionalline"
        detailparams: {edit: true, tab: {…}, card: {…}}
        gridparams: {show: true, edit: false}
        filterable: true
        sortable: true
        type: 1
        editor: {model: ƒ}
        filter: {model: ƒ}
        grouping: {getter: "deliveryaddressadditionalline", collapsed: false, formatter: ƒ}
        rerenderOnResize: true
        }
    3: {
        id: "edit"
        name: ""
        field: ""
        width: 30
        formatter: ƒ (row, cell, value, columnDef, dataContext)
        onCellClick: (e, args) => { this.gotoDetailPane(e, args, detailInfo); }
        gridparams: {show: true}
        fieldtype: "edit"
        }
    4: {id: 1, fieldtype: "string", name: "id", json_translate_property: null, field: "id", …}
}

gridOptions: {
    enableColumnPicker: false
    headerMenu: {hideColumnHideCommand: true}
    enableGridMenu: false
    enableAutoResize: true
    autoResize: {containerId: "grid-container", sidePadding: 15}
    enableSorting: undefined
    autoEdit: false
    editable: true
    enableCellNavigation: true
    enableFiltering: true
    rowSelectionOptions: {selectActiveRow: true}
    enableRowSelection: true
    showHeaderRow: true
    showTopPanel: false
    enableDraggableGrouping: true
    createPreHeaderPanel: true
    showPreHeaderPanel: false
    preHeaderPanelHeight: 40
    draggableGrouping: {
        dropPlaceHolderText: "Drop a column header here to group by the column", 
        deleteIconCssClass: "fa fa-times", 
        onGroupChanged: ƒ, 
        onExtensionRegistered: ƒ
    }
    explicitInitialization: true
}

The images below depict various scenarios showcasing unpredictable column shuffling and sporadic appearance/disappearance of filters despite identical source code:

https://i.sstatic.net/gLZ7T.png

https://i.sstatic.net/kDA7j.png

https://i.sstatic.net/z5pNT.png

Answer №1

Take note that the initial two lines of fetchHeaderColumnValue function are:

function fetchHeaderColumnValue(colIdOrIndex) {
  var index = (typeof colIdOrIndex === "number" ? colIdOrIndex : getColumnIndex(colIdOrIndex));

If the value passed in is a number, it will be treated as the 0-based index in the columns array (not the ID). But if it's a string, then it will be used to search for the column array's index by treating it as an ID.

Therefore, your approach is correct; when dealing with numeric IDs, simply convert them to strings before passing them along.

This concept applies more broadly to many instances involving JavaScript objects: obj[2] will look for the second element in an array, while obj['2'] will search for a property named '2' within the object. The code above doesn't pertain to any particular object, but the principle remains consistent.

Answer №2

After some investigation, I was able to identify the issue and come up with a solution:

Within our dataset, we utilize numeric IDs (such as 1, 2, 3, etc.). It appears that there is a discrepancy in the code where the grid mistakenly associates incorrect columns with these numerical IDs. Upon querying the div using grid.getHeaderRowColumn(col.id) and populating it with col.id, it displays a different ID than what was initially assigned. Notably, not all columns were being recognized, resulting in an inability to set filters as intended. By converting the IDs to strings ('id1', 'id2', 'id3', etc.), the issue was successfully resolved!

It remains uncertain whether this anomaly is a bug or a limitation related to dynamic columns. Nevertheless, employing string-based IDs proved effective for the time being. Many thanks to @ghiscoding for the guidance.

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

Preventing the Sending of Origin Header in Angular 2

I am facing an issue in my Angular2 project where the HTTP service is automatically adding the 'Origin' header with a value to all of the requests. Is there a way to stop Angular2 from including this 'Origin' header in the HTTP calls? A ...

Expandable Grid Sections in React MUI

Is there a way to create a grid layout where items with showDefault: true are always displayed at the top, and then users can click an arrow button to expand the grid and also show the items with showDefault: false? Any suggestions on how to achieve this? ...

Angular: How to Disable Checkbox

Within my table, there is a column that consists solely of checkboxes as values. Using a for loop, I have populated all values into the table. What I have accomplished so far is that when a checkbox is enabled, a message saying "hey" appears. However, if m ...

Can the color of text be adjusted (to either white or black) based on the background color (in any color and format)?

To achieve a text color that contrasts well with any background, I need to make sure it's either black or white. The background in my app can vary in color and format, so finding the perfect solution has been challenging. Using mix-blend-mode doesn&a ...

What steps do I need to take to run my Angular project locally using globally installed npm packages?

I'm interested in maintaining all my packages globally, similar to how node package itself operates. For instance, if I have a package named "Highcharts" listed in my package.json file, I prefer to install it globally instead of creating a local node_ ...

Angular 2: The window.crypto.subtle.importKey function functions properly on 'localhost' but encounters issues on an 'ip' address

As a newcomer to Angular 2, I am working on creating a login form that encrypts and sends the user's emailid and password to the server. I have successfully implemented AES-ECB using AES-CTR from the following link: https://github.com/diafygi/webcry ...

The functionality for handling gestures on AgmMap appears to be non-functional

I am currently using the AGM Map feature available on and I need to disable the zooming functionality when scrolling. Despite setting gestureHandling = "'cooperative'", it does not seem to work. Are there any specific factors causing this issue? ...

Error in Typescript SPFx: The property 'news' is not found in the type 'Readonly<{}>'

Currently, I am working on developing a spfx react component to showcase an RSS feed in the browser. My prototype is functional in a test environment, however, as spfx utilizes TypeScript, I am encountering a type error that I am unsure how to resolve. Rs ...

Angular 2: Issue with data table not updating after item deletion

I need assistance with updating a data table after deleting an item. The database is updated correctly when I delete an item, but the table does not automatically refresh to reflect the changes. managenews.component.ts import { Component, OnInit } from ...

I'm looking for the configuration of function definitions for the Jasmine npm module within an Angular project. Can

When a new Angular project is created, the *.spec.ts files provide access to Jasmine functions such as "describe", "beforeEach", and expect. Despite not having an import clause for them in spec.ts files, I can click on these functions and navigate to their ...

ng serve: Module 'tapable' not found

After moving my Angular 5 project to a new computer, I encountered an issue when attempting to ng serve: Cannot find module 'tapable' Error: Cannot find module 'tapable' at Function.Module._resolveFilename (module.js:469:15) at ...

What is the best way to access the underlying native view window of a Nativescript Angular modal?

I have been attempting to enable Immersive mode exclusively in a modal page. However, when I implement the following code within the ngOnInit of the modal component: Application.android.foregroundActivity.getWindow().getDecorView().setSystemUiVisibility( ...

Error: Element type is invalid: a string was anticipated, but not found

I recently experimented with the example provided in React's documentation at this link and it functioned perfectly. My objective now is to create a button using material-ui. Can you identify what is causing the issue in this code? import * as R ...

Newly added rows do not automatically refresh in Angular's mat-table

(Angular 8) I am working with two components, addgame and home. In the home component, I am displaying all games stored in the database using a REST API. Within the home component, I am calling the game component in a dialog view using Mat-dialog. The i ...

Angular 2, Release Candidate 5 - Dropdown form includes mysterious "phantom" choice

While working with Angular 2, RC 5, I have encountered a strange issue while building a form to create a new model object. The problem arises when there is an extra blank <option> appearing in the dropdown list after transpiling the code, even though ...

Error thrown when using React Router DOM: FC{} | ReactNode is not compatible with type ReactNode

Recently, I started using TypeScript and delving into a project that involves the react-router-dom. However, as I attempt to create elements in my App.tsx file, an error keeps popping up. Let's take a look at the code snippet: <Route path="la ...

Unable to load content from Three.js Examples library (Error loading script for "three/examples/jsm/loaders/OBJLoader2")

In my Angular application, I have a simple setup using Three.js. When I try to import the `OBJLoader2` from `three/examples/jsm/loaders/OBJLoader2`, everything works fine except when running it with the `ts_devserver`. The browser console shows an error: G ...

Does the latest stable version of Angular2 come with a named-routerOutlet feature?

<router-outlet name="another_name"></router-outlet> & the routes are defined as {path: '', component: AnotherComponent} TS is not able to identify this. 'name' is not a valid route parameter Any suggestions on how to ...

I'm wondering why my JWT token appears as null on the backend while it is not null on the frontend

I'm having trouble with a GET request to my mLab database. I included a JWT token in the request and verified it on both the client and server side. Strangely, it appears correctly on the client but as null on the server. Any assistance on this matter ...

Accessing Github REST API with Next-auth token

Looking to enable user login and retrieve specific user data using the Github REST API, such as repositories and issues. After successfully implementing the login feature, I encountered an obstacle with the Github REST API that requires a token for endpoi ...