ksv works with array

by slawe

JavaScript

console.clear();
'use strict';

// define vars
var columns = [],
		//columns that are not listed, will be skipped
    renameCol = {
    	id: '#',
      invoice_name: 'Name',
      resolved: 'SOLVE'
    },
    sortCol = [],
		rows = [];
// actual data works
var extData = [
	{id: 1, invoice_name: 'someNameOne', file_id: 4, resolve: true, $$key: 022},
	{id: 3, invoice_name: 'someNameTwo', file_id: 4, resolve: false, $$key: 058},
	{id: 7, invoice_name: 'someNameThree', file_id: 1, resolve: true, $$key: 017},
];

// init
function init() {
	return getDbCol(extData), fireUpCol(columns);
}

// real db columns
function getDbCol(cols) {
	for(var i in cols[0]) {
  	if(i !== '$$key') {
    	columns.push(i);
    }
  }
}

// skip & rename columns
function fireUpCol(cols) {
	for(var i in cols) {
  	console.log(cols[i]);
  }
}

init();
console.log(columns);