Never stop learning, approaching the AI
  • 😄About
  • 🅰️AI-Candy on YouTube
    • 🎬YouTube 视频列表
    • 💠AI项目本地部署
      • 1️⃣安装 Pytorch 运行环境
      • 2️⃣在Python虚拟环境下使用 VS Code or PyCharm
        • VS Code Python format
      • 3️⃣Create python virtual environment in Linux
    • 👽AI 入门系列课程
      • 0️向量及向量运算
        • Reshape array code
      • 1️人工智能,机器学习,深度学习 和神经网络的区别
      • 2️卷积神经网络(CNN)
        • 3D CNN sample code
      • 3️Transformer 原理
      • 4️前馈神经网络 (FNN)
  • 🎭Artificial intelligence
    • 1️⃣Deep learning / machine learning
      • 👉Deep Learning Resources
      • 👉Deep learning notes
    • 2️⃣Python
      • Youtube音乐下载
      • Pytorch 安装环境配置 (old)
        • TorchEEG
      • Anaconda3 Python path
      • Data
      • IEEE-754 Floating Point Converter
        • ieee 754 conversion function
      • 文件读写
      • 文本清理
      • Python 下载在线视频
      • 修改Jupyter Notebook 默认工作目录
    • 3️⃣AI Websites
  • 🪤Programming
    • SQL
      • Delete data and reset auto-increment ID
    • Angular
      • Angular-datatables, dd/MM/yyyy, sorting (no paged list)
      • Datatables save state using localStorage
      • Variable storage method
      • Colour picker
      • Error fix for click columns on Datatable
      • Auto address use Google place
      • Auto address use Azure Maps
      • Upload file to Server
      • Validators.required OnChange input
      • Date, Time field
      • VS Code: Auto add missing imports when save
      • Datatable setting
      • Date time format
      • sticky <th> and <td> content
      • Filter booked time
      • Dropdown time selection with interval
      • Angular date online test
      • Updating data without refreshing the page
      • Object array sort and sum
      • Multi-type of columns use in one column
      • Select button for datatables
      • Switch button and event
      • Delete column from Array
      • Three-layer structure
      • Remove shadow when print mat-dialog content
      • JSON Parse && Object Array
      • Detect unused import in Typescript
      • Change location using radio button
      • display multi line message in the Toastr
      • Custom LOCALE_ID
      • Batch add data from csv to API server
        • Angular read csv and upload to Server
      • USB Port reader Web solution
      • Debug Angular app using JavaScript Debugger in VS Code
      • Skills
        • FormData & FormGroup to JSON
        • Dropdown list (customer)
        • Get current datetime
        • Get first day of year, month, and date
        • Call a function in a forEach loop
        • disable and readonly
        • Form element value
        • HTML input type
        • Input pattern (validation)
      • Display pipe (UI format)
        • Input upper case and button checked
        • Icons (Bootstrap and CoreUI)
        • Page Refresh
        • Selection list (two ways)
        • onChange Selection event
        • Random Password and Toggle
        • Password match
        • Select checkbox disable
      • Print and save to PDF
      • Import JS into Angular
      • LocalStorage
      • Angular DataTable
        • Data sort
        • A sample usage
        • Angular DataTable server side big data query
      • Change chart.js chart type
      • Angular UI - .NET API - .NET Auth
      • Angular - .NET API
      • *ngIf else && change to @if
      • Angular add reCAPTCHA v3 (Google)
      • Angular update
        • Update from v13 to v15
        • Update from v15 to v18
      • Angular application version central
      • Face detection
        • Face-api.js
      • Angular, Node version compatibility matrix
      • Clear cache
      • Angular oauth2 OIDC
      • Angular add header
    • .NET Skills
      • Add ID manually
      • Auto Mapping
        • Ignore Nesting
        • Startup setting
        • Datetime processing in AutoMapping
        • AutoMapper example
      • Validation filter
      • BaseController
      • Group by many
      • Database first, scaffold to class
      • Log setting and exception handler
      • Update appsetting.json value
      • Azure service bus message (queue)
      • Read appsetting.json value
      • Auth get user info by email
      • Azure Time zone
      • .NET API Add Service
      • Object comparison
      • Coravel Schedule
        • Read appsettings.json
      • .Net Core RDLC Report, Coravel and Email
      • Check Network and SQL server connections.
      • Datatime custom format
      • Many to Many EF
        • Many to Many CheckBox
      • PDFpig: Send Email with PDF attachment
      • .NET Core Middleware order
      • .NET API add Worker Service
      • .NET Router
      • Partial columns update
      • Add and Delete
      • 图片自适应宽度
      • ASP.NET Identity
      • Upload file to Azure
        • Upload file to Blob
      • Developer Guide
      • Code first one-many
      • ASP.NET MVC 5 Custom Error Page
      • VS can't debug
      • 通过邮编查 NSW COVID-19 感染人数
      • Jquery File Upload
      • Jquery Datepicker
      • ajax delete file from server
      • Autofac in MVC
      • Autofac in .NET Core
      • .NET Core
      • HTTP Return code
      • IdentityServer4
    • Power BI
      • Add parameter to PowerBI report
      • Convert UTC to Local time
      • Python in PowerBI
        • IEEE-754 conversion
      • PowerBI embed app - Server
      • PowerBI embed app - Client
        • Setting on portal
    • Azure service
      • Key Vault
      • Service bus - queue
      • Power Automate
      • Kusto Query Language
      • Azure Data Explorer
      • Reserved keyword on Azure Error
      • SQL Azure time convert
    • Azure blob
      • Azure blob setting
      • Display image from Blob
      • Upload image to Blob through .NET API
    • Html Bootstrap Icon, colour, size
      • Html spacing
      • Html text alignment
    • Video stream - JsMpeg
      • SSL - generate key
      • Client (SSL)
      • Websocket-Server (SSL)
      • Play RTSP video stream
    • ⏰Time Zone
      • datetime-local set date range
      • 🕐Get data by local time (UI, API)
      • 🕑Add offset hours for local UI and report
      • 🕒UTC time and Datetime convert
      • 🕓Angular - Timezone selection
      • 🕔Angular - Convert UTC to local time
      • 🕕C# Time Zone
  • >>>>>>>>>>>>>>>>>>>>>>>>>>>>
  • 🪜Apps and Skills
    • 1️Windows system app skills
      • Brother HL-2130 打印机 Toner 报警
      • VS Code 快捷键
      • Check SHA256 on windows
      • blob 视频下载
      • Photoshop 制作证件照片
      • 获取 Windows Key
      • 10进制36进制互转
      • Error when publish to Azure
      • Disable windows automatic update
      • Outlook setup for Yahoo Email
      • IIS setting
      • Windows 8/10, IIS Service
      • 安装程序出错 2052,2053 报警
      • 6 Yao Chinese UI
    • 2️Linux command
    • 3️Git command
    • 4️Bitbucket
    • 5️Gitbook Skills
    • 6️GitHub Desktop
    • 7️⃣EndNote
      • EndNote V21
      • Endnote使用技巧
      • 批量删除/修改Endnote 中 notes 栏内容
  • Android mobile connect PC
  • 💎USEFUL LINKS
    • 1️Coding websites
      • Website links
    • 2️Windows 平台工具,网站
    • 3️PotPlayer 设置
  • >>>>>>>>>>>>>>>>>>>>>>>>>>>>
  • 🚩Research >>EEG
    • 1️EEG基本知识的理论介绍
      • EEG 简介
      • EEG 的节律信号
      • EEG电极帽
      • EEG 伪迹
      • ERP 介绍
      • ERP 成分
      • EEG 数据分析软件
    • 2️LSL 应用
    • 3️EEG公开数据集汇总整理
    • 4️REDCap
      • Migration (Export & Import)
    • 5️⃣ScaneR
  • ☕Buy me a coffee
Powered by GitBook
On this page

Was this helpful?

  1. Programming
  2. Angular

Datatable setting

  • Column display using ajax

Data with two decimal places and align right:
   return '<span  class="text-info" style="float: right;">' + formatNumber(Number(row.weight2P1), locale, '1.2-2') + '</span>';

Data align: center (div)
   return '<div class="text-success" style="text-align: center;"> Yes</div>';

Datetime:
   return '<span  class="text-success" >'+ formatDate(new Date(data), 'dd/MM/yyyy hh:mm:ss a', 'en-AU'
input.ng-invalid.ng-touched {
  border: rgb(233, 168, 168) 1px solid;
  box-shadow: 0px 0px 6px  #9191ee;
}

  • input colour, field focus color


input.ng-invalid.ng-touched {
  border: rgb(233, 168, 168) 1px solid;
  box-shadow: 0px 0px 6px  #9191ee;
}
  • /input, select field focus colour
    -----------------------------------
        datatables.net@2.1.6
    -----------------------------------
    .dt-container .dt-length {
      select:focus {
        outline: none !important;
        border: 1px solid rgb(213, 213, 245);
        box-shadow: 0px 0px 6px  #9191ee;
      }
    }
    
    .dt-container .dt-search {
      input:focus {
        outline: none !important;
        border: 1px solid rgb(213, 213, 245);
        box-shadow: 0px 0px 6px  #9191ee;
      }
    }
    
    -----------------------------
      datatables.net@1.13.4
    -----------------------------
    
    .dataTables_length {
      select:focus {
        outline: none !important;
        border: 1px solid rgb(213, 213, 245);
        box-shadow: 0px 0px 6px  #9191ee;
      }
    }
    
    .dataTables_filter {
      input:focus {
        outline: none !important;
        border: 1px solid rgb(213, 213, 245);
        box-shadow: 0px 0px 6px  #9191ee;
      }
    }
    
  • Table line-height

    ::ng-deep td {
      padding: 5px !important;
      line-height: 36px !important;
    }
    
    
    table.table tr {
     line-height: 26px !important;
    }
    
  • Button position

    dom:
          "<'row'<'col-sm-3'l><'col-sm-6 text-center'B><'col-sm-3 pull-right'f>>" +
          "<'row'<'col-sm-12'tr>>" +
          "<'row'<'col-sm-5'i><'col-sm-7 text-right'p>>",
    buttons: [
      {
        extend: 'createState',
        config: {
          creationModal: true,
          toggle: {
            columns: {
              search: true,
              visible: true,
            },
            length: true,
            order: true,
            paging: true,
            scroller: true,
            search: true,
            searchBuilder: true,
            searchPanes: true,
            select: true,
          },
        },
      },
      'savedStates',
      'removeAllStates',
      'colvis', 'copy', 'csv', 'pdf', 'excel', 'print',
    ],
    

    ::ng-deep.dt-type-numeric.sorting_1{
      padding: 4px!important;
    }
    
    th{
      line-height: 30px !important;
    }
    
    ::ng-deep.dt-info {
      padding-top: 12px!important;
    }
    
    ::ng-deep .dt-paging {
      padding-top: 5px!important;
    }
    
    ::ng-deep.dt-search{
      text-align: right!important;
    }
    
    div{
      overflow-x: hidden;
    }
    
  • ajax

      ajax: (dtParameters: any, callback: any) => {
        this.isLoading = true;
        this.weighingService.getAllWeighingPagedList(dtParameters, customerName)
          .pipe(
            finalize(() => {
              this.isLoading = false;
            })
          )
          .subscribe({
            next: resp => {
              callback({
                recordsTotal: resp.recordsTotal,
                recordsFiltered: resp.recordsFiltered,
                data: resp.data  // set data
              });
    
              this.isLoading = false;
              // setTimeout(() => {
              //   $($.fn.dataTable.tables(true)).DataTable().columns.adjust();
              // }, 200);
            },
            error: error => {
              this.toastr.error(error)
            }
          });
      },
    
      columns: [{
        data: 'transactionno', render: function (data: any, type: any, row: any) {
          if (row.status != 'F')
            return '<span style="color:red; display: flex; justify-content: center; align-items: center; ">' + data + '</span> '
          else
            return '<span style="color:blue; display: flex; justify-content: center; align-items: center; ">' + data
              + ' <button mat-button class="btn btn-sm" (click)="print("print",dataItem)> <span class="pointer" style="font-size:larger"><i class="fa fa-print text-success" title="Print docket"></i></span></button> ' +
              '</span>'
        }
      },
      { data: 'binInfo' },
      
      {
        data: 'carrier', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span  class="text-info" style="float: right;">' + row.carrier + '</span>';
          else
            return ''
        }
      },
      { data: 'rego' },
      {
        data: 'product', render: function (data: any, type: any, row: any) {
    
          return '<span  class="text-warning">' + row.product + '</span>';
        }
      },
      {
        data: 'unitPrice', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span  class="text-success" style="float: right;">' + formatNumber(Number(row.unitPrice), locale, '1.2-2') + '</span>';
          else
            return ''
        }
      },
      { data: 'weighType' },
      {
        data: 'net', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span  class="text-success" style="float: right;">' + formatNumber(Number(row.net), locale, '1.2-2') + '</span>';
          else
            return ''
        }
      },
      {
        data: 'tare', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span style="float: right;">' + formatNumber(Number(row.tare), locale, '1.2-2') + '</span>';
          else
            return ''
        }
      },
      {
        data: 'gross', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span  class="text-success" style="float: right;">' + formatNumber(Number(row.gross), locale, '1.2-2') + '</span>';
          else
            return ''
        }
    
      },
      {
        data: 'timestamp1', render: function (data: any, type: any, row: any) {
          return '<span class="text-success" >' +
            formatDate(new Date(data), 'dd/MM/yyyy hh:mm:ss a', 'en-AU')
        }
      },
      {
        data: 'weight1', render: function (data: any, type: any, row: any) {
          return '<span class="text-success" style="float: right;">' + formatNumber(Number(row.weight1), locale, '1.2-2') + '</span>';
        }
      },
      {
        data: 'weight1P1', render: function (data: any, type: any, row: any) {
          if (data != null && data != 0)
            return '<span class="text-success"  style="float: right;">' + formatNumber(Number(row.weight1P1), locale, '1.2-2') + '</span>';
          else
            return ''
        }
      },
      {
        data: 'timestamp2', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span  class="text-info">' +
              formatDate(new Date(data), 'dd/MM/yyyy hh:mm:ss a', 'en-AU');
          else
            return ''
        }
      },
      {
        data: 'weight2', render: function (data: any, type: any, row: any) {
          if (data != null)
            return '<span  class="text-info" style="float: right;">' + formatNumber(Number(row.weight2), locale, '1.2-2') + '</span>';
          else return ''
        }
      },
      {
        data: 'weight2P1', render: function (data: any, type: any, row: any) {
          if (data != null && data != 0)
            return '<span class="text-info" style="float: right;">' + formatNumber(Number(row.weight2P1), locale, '1.2-2') + '</span>';
          else return ''
        }
      },
      { data: 'bookingNo' },
      {
        data: 'status', render: function (data: any, type: any, row: any) {
          return '<span class="text-info" style="text-align: center">' + data + '</span>';
        }
      },
      ],
      rowCallback: (row: Node, data: any[] | Object, index: number) => {
        const self = this;
        // Unbind first in order to avoid any duplicate handler
        // (see https://github.com/l-lin/angular-datatables/issues/87)
        // Note: In newer jQuery v3 versions, `unbind` and `bind` are
        // deprecated in favor of `off` and `on`
    
        $('button', row).off('click');
        $('button', row).on('click', () => {
          self.printClickHandler(data);
        });
        return row;
      }
    };
    }
    
    printClickHandler(weighingData: any): void {
    this.printDialog(weighingData);
    }
    
    printDialog(weighingData: any) {
    this.dialog.open(PrintticketComponent, {
    
      width: '780px',
      height: 'auto',
      data: { weighingData }
    })
      .afterClosed().subscribe(result => {
        console.log(`Dialog result: ${result}`);
      });
    }
  • sticky column

    .stickyColumn {
      position: sticky !important;
      left: 0 !important;
      background-color: rgb(215, 219, 214);
      // overflow: hidden;
      z-index: 1;
    }

//  it be used for paged list

::ng-deep .sticky-col {
  position: sticky;
  left: 0;
  background-color:rgb(231, 233, 230) !important;
  z-index: 12;
}



columns: [
  {
    data: 'id', render: function (data: any, type: any, row: any) {
      if (role === 'Administrator' || role === 'Supervisor') {
        let content = '<div style="text-align: center;" ><button mat-button (click)="editDialog("Edit",dataItem)" class="btn btn-outline-warning btn-sm edit-btn">' +
          '<i class="fa fa-edit" title="Edit"></i></button> <span class="pe-1"></span>'
        if (!isForCustomer) {
          content = content + ' <button mat-button (click)="deleteDialog(dataItem.id, dataItem.rego)" class="btn btn-outline-danger btn-sm delete-btn">' +
            '<i class="fa fa-trash" title="Delete"></i></button></div>'
        }
        return '<div style=" width:80px; background-color: rgb(230, 233, 230)!important">' + content + '</div></div>'
      }
      else
        return ''
    },
   className: 'sticky-col'   ///<<<<<<<<<
  },

PreviousVS Code: Auto add missing imports when saveNextDate time format

Last updated 3 months ago

Was this helpful?

🪤