Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular table lazy loading

  onFileSelected(files: FileList) {

    console.log(files)
    console.log(files[0])

    this.csvIsParsing = true;

    let file = files[0];
    // xls is the same MIME type like csv
    let csvType = "application/vnd.ms-excel";
    let xlsxType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

    if (file.type !== csvType && file.type !== xlsxType) {
      this.wrongFileTypeError = true;
      this.csvIsParsing = false;
      return;
    } else if (files.length > 1) {
      this.tooManyFilesError = true;
      this.csvIsParsing = false;
      return;
    }

    this.fileName = file.name;
    this.checkFileSize(file.size);

    this.wrongFileTypeError = false;
    this.tooManyFilesError = false;

    if (files.length > 0 && file.type === csvType) { //temporarily

      this.csvParser.parse(file, {
        header: this.hasCsvHeader,
        skipEmptyLines: true,
        dynamicTyping: true,
        // dynamicTyping: true, lässt 0 verschwinden vor 010000
        encoding: "ISO-8859-1",
        complete: (result) => {
          console.log('Parsed: ', result.data);
          this.csvData = result.data;
          this.dataSource = new MatTableDataSource(result.data);
          this.dataSource.sort = this.sort;
          setTimeout(() => this.dataSource.paginator = this.paginator);
          for (let col in this.csvData[0]) {
            this.displayedColumns.push(col);
          }
          console.log(this.dataSource);
          this.csvIsParsing = false;
        }
      });
    }
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript to prevent method POST from realoading 
Javascript :: https://stackoverflow.com/questions/19380738/mongoose-nested-query-on-model-by-field-of-its-referenced-model 
Javascript :: parent.containts js 
Javascript :: full calendar change default view 
Javascript :: fetchapi snippet 
Javascript :: mdn spread 
Javascript :: reading data from link in javascript 
Javascript :: swift read json from url 
Javascript :: form validation jflutter 
Javascript :: como fazer piramade de asteriscos 
Javascript :: dynamic components 
Javascript :: use only dispatch from useContext 
Javascript :: url(image loacation) give a class 
Javascript :: how to set up click event listeners javascript 
Javascript :: how to refresh a page in javascript 
Javascript :: TOTAL 
Javascript :: change the body background color with javascript 
Javascript :: shopify get values from settings_data.json 
Javascript :: socket io across two different ports 
Javascript :: enzyme to json 
Javascript :: ameca face expression code xcode 
Javascript :: everything about fetch 
Javascript :: object.keys map 
Javascript :: hello worled anglular script 
Javascript :: mongoose undo delete 
Javascript :: multiple filter html table using javascript 
Javascript :: how to generate password hash and a salt in nodejs 
Javascript :: what is the opposite of lazy initialization 
Javascript :: inherit mdn 
Javascript :: && in react jsx 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =