Author Topic: I need to make a basic grid with pqrid, and it doesn't show me data  (Read 530 times)

TenarisDev

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 7
    • View Profile
good afternoon, I need to make a basic grid with pqrid, and it doesn't show me data
app.component.ts
import { Component, OnInit } from '@angular/core';

import pq from 'pqgrid';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],


})
export class AppComponent implements OnInit {

  ngOnInit(): void {

    //or array of objects
    var dataSales = [
      { rank: 1, company: 'Exxon Mobil', revenues: '339,938.0', profits: '36,130.0' },
      { rank: 2, company: 'Wal-Mart Stores', revenues: '315,654.0', profits: '11,231.0' },
      { rank: 3, company: 'Royal Dutch Shell', revenues: '306,731.0', profits: '25,311.0' },
      { rank: 4, company: 'BP', revenues: '267,600.0', profits: '22,341.0' },
      { rank: 5, company: 'General Motors', revenues: '192,604.0', profits: '-10,567.0' }];
    //Initialize pqGrid with data.
    pq.grid('app-root', { dataModel: { data: dataSales } });

  }

  title = 'web-portal';


}
--------------
app.component.html

<app-root></app-root>
------------------------
angular.json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "web-portal": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/web-portal",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css",
              "./node_modules/jquery-ui-pack/jquery-ui.css"
             
            ],
            "scripts": [
              "./node_modules/jquery/dist/jquery.min.js"
            ]
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "62kb",
                  "maximumError": "4kb"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true,
              "aot": false
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "web-portal:build:production"
            },
            "development": {
              "browserTarget": "web-portal:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "web-portal:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        }
      }
    }
  },
  "cli": {
    "analytics": false
  }
}
=====
package.json
{
  "name": "web-portal",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^16.0.0",
    "@angular/common": "^16.0.0",
    "@angular/compiler": "^16.0.0",
    "@angular/core": "^16.0.0",
    "@angular/forms": "^16.0.0",
    "@angular/platform-browser": "^16.0.0",
    "@angular/platform-browser-dynamic": "^16.0.0",
    "@angular/router": "^16.0.0",
    "jquery": "^3.7.0",
    "pqgrid": "^9.0.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.13.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^16.0.3",
    "@angular/cli": "~16.0.3",
    "@angular/compiler-cli": "^16.0.0",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.6.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~5.0.2"
  }
}
when making ng serve -o showed me


./node_modules/jquery-ui-pack/jquery-ui.css:9:0 - Error: Module parse failed: Unexpected token (9:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /* Layout helpers
| ----------------------------------*/
> .ui-helper-hidden {
|       display: none;
| }

./node_modules/jquery-ui-pack/jquery-ui.structure.css:13:0 - Error: Module parse failed: Unexpected token (13:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /* Layout helpers
| ----------------------------------*/
> .ui-helper-hidden {
|       display: none;
| }

./node_modules/jquery-ui-pack/jquery-ui.theme.css:17:0 - Error: Module parse failed: Unexpected token (17:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /* Component containers
| ----------------------------------*/
> .ui-widget {
|       font-family: Arial,Helvetica,sans-serif;
|       font-size: 1em;



× Failed to compile.


I appreciate your help,thanks
« Last Edit: June 27, 2023, 02:03:48 am by TenarisDev »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: I need to make a basic grid with pqrid, and it doesn't show me data
« Reply #1 on: June 27, 2023, 06:01:48 am »
have you set it up manually or have you used angular-cli?

From the errors it looks like you are missing css loader in webpack.config.js: Please check your webpack version for the correct syntax.

Code: [Select]
module: {
    rules:[
        { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] }
    ]
}

TenarisDev

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: I need to make a basic grid with pqrid, and it doesn't show me data
« Reply #2 on: June 29, 2023, 12:49:50 am »
I have a way to fix it without using webpack

TenarisDev

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: I need to make a basic grid with pqrid, and it doesn't show me data
« Reply #3 on: June 30, 2023, 01:34:02 am »

added webpack.config.js
module.exports = {

    module: {
        loaders: [
            { test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: { presets: ['es2015'] } }, ,
            { test: /\.css$/, loader: 'style!css', exclude: /node_modules/ }
        ]
    }
    ,
    rules: [
        {
            test: /\.css$/,
            loader: ['style-loader', 'css-loader']
        },
        {
            test: /\.css$/,
            exclude: helpers.root('src', 'app'),
            loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' })
        },
        {
            test: /\.css$/,
            include: helpers.root('src', 'app'),
            loader: 'raw-loader'
        }
    ]
}
==================
package.json
{
  "name": "web-portal",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "builddev": "webpack --mode development"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "15.0.3",
    "@angular/compiler": "15.0.3",
    "@angular/core": "15.0.3",
    "@angular/forms": "15.0.3",
    "@angular/platform-browser": "15.0.3",
    "@angular/platform-browser-dynamic": "15.0.3",
    "@angular/router": "15.0.3",
    "@types/jquery": "3.3.29",
    "@types/jqueryui": "1.12.7",
    "core-js": "2.6.5",
 
    "jquery": "1.12.2",
    "jquery-ui-pack": "",
    "jszip": "2.5.0",
    "pqgrid": "^9.0.0",
    "rxjs": "6.5.3",
    "zone.js": "~0.13.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.3",
    "@angular/cli": "^15.0.3",
    "@angular/compiler-cli": "^15.0.3",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.6.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": ">=4.8.2 and <4.9.0"
  }
}
===


./node_modules/jquery-ui-pack/jquery-ui.css:7:0 - Error: Module parse failed: Unexpected token (7:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| * Copyright jQuery Foundation and other contributors; Licensed MIT */
|
> .ui-draggable-handle {
|       -ms-touch-action: none;
|       touch-action: none;

./node_modules/jquery-ui-pack/jquery-ui.structure.css:11:0 - Error: Module parse failed: Unexpected token (11:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|  * http://api.jqueryui.com/category/theming/
|  */
> .ui-draggable-handle {
|       -ms-touch-action: none;
|       touch-action: none;

./node_modules/jquery-ui-pack/jquery-ui.theme.css:17:0 - Error: Module parse failed: Unexpected token (17:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /* Component containers
| ----------------------------------*/
> .ui-widget {
|       font-family: Arial,Helvetica,sans-serif;
|       font-size: 1em;


PS C:\Users\web-portal> webpack --mode development
[webpack-cli] Failed to load 'C:\web-portal\webpack.config.js' config
[webpack-cli] ReferenceError: helpers is not defined
    at Object.<anonymous> (C:\web-portal\webpack.config.js:17:22)
thank you so much


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: I need to make a basic grid with pqrid, and it doesn't show me data
« Reply #4 on: June 30, 2023, 08:06:48 am »
your webpack.config.js is incorrect:

rules is a property of module.

Code: [Select]
module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader'
        ]
      }
    ]
  }