Giter Site home page Giter Site logo

berxpert / ag-grid-server-side-postgresql Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 358 KB

A reference implementation showing how to perform server-side operations using ag-Grid with C# and PostgreSQL

License: MIT License

C# 75.93% Shell 0.16% TypeScript 20.19% HTML 2.76% CSS 0.29% JavaScript 0.67%

ag-grid-server-side-postgresql's Introduction

Ag-Grid Server side using Postgres as the backend DB

About

This is a basic implementation of Postgresql as the server side provider for AG-Grid for Angular and Dotnet.

The implementation follows the guide of the Server-Side Row Model SSRM at the Ag-grid documentation site.

Similar to the samples provided by Ag-grid, this implementation provides infinite scroll, row grouping, filtering and pivoting for the data set Olympic winners.

Live demo

This code is running as an Azure static app with an API based on Azure function here

Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You need to have a machine with dotnet > 8, node > 18 and npm > 8 installed.

$ dotnet --version
8.0.100

$ node --version  
v18.12.1

$ npm --version
8.19.2

You will also need to setup the table and insert the sample records in your Postgresql database.

Set the required environment variables

You will need to define the db_connection in your config file or as a user-secret to connect to your Postgresql database.

For example: using dotnet user-secrets

dotnet user-secrets init

dotnet user-secrets set "db_connection" "Server=yourServer;Port=5432;user id=userId;password=yourPassword" --project Api

Installing, Testing, Building

The build process is handled by dotnet and npm. Both applications will download any required libraries.

To run the backend API

Run the following command on the root folder:

dotnet run --project WebApi

The Api will be listening on the http://localhost:5049 address. The application logs should display something similar to:

Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5049
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /Users/berxpert/code/ag-grid-server-side-postgresql/Api

To run the Angular client

On a second terminal, run the following command on the root folder:

cd Client
npm install
npm start

The Angular Web app will be hosted at http://localhost:4200/

The npm command log should display something like:

Initial Chunk Files   | Names         |  Raw Size
vendor.js             | vendor        |   6.74 MB | 
styles.css, styles.js | styles        | 415.79 kB | 
polyfills.js          | polyfills     | 314.27 kB | 
main.js               | main          |  10.81 kB | 
runtime.js            | runtime       |   6.51 kB | 

                      | Initial Total |   7.47 MB

Build at: 2022-12-22T21:02:06.893Z - Hash: 5467cf94f11cf08c - Time: 2578ms

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


โœ” Compiled successfully.

If you need help using the Ag-Grid visit the official documentation.

Test Ag grid request

You can call the API directly simulating the Ag-grid requests from the Client. Some samples are in the requests folder, for example the BasicQuery.http request returns all the fields for the rows 5 and 6 on the dataset:

POST http://localhost:5049/api/winners
Content-Type: application/json

{
    "StartRow" : 5,
    "EndRow" : 6,
    "RowGroupCols" :[
    ],
    "ValueCols" : [],
    "PivotCols" : [],
    "GroupKeys" : [],
    "SortModel" : [],
    "filterModel": {}
}

Response:

{
  "data": [
    {
      "athlete": "Alicia Coutts",
      "age": 24,
      "country": "Australia",
      "country_group": "A",
      "year": 2012,
      "date": "12/08/2012",
      "sport": "Swimming",
      "gold": 1,
      "silver": 3,
      "bronze": 1,
      "total": 5
    },
    {
      "athlete": "Missy Franklin",
      "age": 17,
      "country": "United States",
      "country_group": "U",
      "year": 2012,
      "date": "12/08/2012",
      "sport": "Swimming",
      "gold": 4,
      "silver": 0,
      "bronze": 1,
      "total": 5
    }
  ],
  "lastRow": 0,
  "secondaryColumns": []
}

ag-grid-server-side-postgresql's People

Contributors

berxpert avatar

Stargazers

Chapin avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.