• Ivy Seo

ngx-datatable ver. 1

How is how I created a data table :


component.html file:

<p style="font-weight: bold; font-size: larger; color: yellow;"> M7 Log Data Report </p>
<ngx-datatable class="ngx-datatable" style=
" border-spacing: 3%;  padding: 2%;"

  [columnMode]="ColumnMode.force"
  [headerHeight]="50"
  [footerHeight]="50"
  [rowHeight]="'auto'"
  [limit]="50"
  [columns]="columns"
  [rows]="rows" 
  [scrollbarH]="true"
 >
</ngx-datatable>


component.ts file:

 export class FilterBarComponent implements OnInit {

 constructor(private http: HttpClient){}    

 ngOnInit() {
 this.get_m7log_data();
  }

 columns = [
      { name: 'logdate' },   
      { name: 'direction' },
      { name: 'latend' },
      { name: 'lathemi' },
      { name: 'lonend' },
      { name: 'lonhemi' },
      { name: 'mph' },
      { name: 'county' },
      { name: 'road' },
      { name: 'linetype' }
  ];

 rows = [];
 @ViewChild(DatatableComponent) table: DatatableComponent;

 // get m7 log  data from back-end and insert its data into the row of the table
 get_m7log_data() {  
 this.http 
      .get('http://127.0.0.1:8088/viewdata/m7log_data')
      .subscribe(data => {    // data returned
 let data_check: any = data; // set as 'any'
 this.rows = data_check; // returned data => rows []
      });
    }
}

Recent Posts

See All

Generate unique filename: UUID, Path

A: using UUID let my_uuid = Uuid::new_v4(); let file_created = File::create(my_uuid.to_string()).expect("create file failed");     println!("uuid: {}", my_uuid); //  buffer write let mut file_ge

JSON - write .txt file in Rust

pub fn serialize_writeFile(data : &full_data ) -> Result<bool, modbus::Error> { // 1) takes data  // this function takes the m7_data object and serializes the contents and saves the results to a text

Serialize/Deserialize JSON in Rust

This README has some good examples. To deserialize in Rust: use serde::{Deserialize, Serialize}; use serde_json::Result; #[derive(Serialize, Deserialize)] struct Person {     name: String,     age: u