I am working through the Drag Drop Example an would like to read in data from a csv.
I would like to reformat the returned data from my csv file into a needed format. In a drag and drop scenario, the dragged element has a value from Array[3] and is dropped on an element with r1val(n). When those values match an event occurs. I would like to find a way to set the values of the first column as key as shown in the Object below.
file.csv:
col1,col2,col3,col4
r1val1,r1val2,r1val3,r1val4
r2val1,r2val2,r2val3,r2val4
....
needed format:
var colSet = {
r1val1 : ["r1val2","r1val3","r1val4"],
r2val1 : ["r2val2","r2val2","r2val2"],
...
}
console.log of needed format:
Object
r1val1: Array[3]
r2val1: Array[3]
...
__proto__: Object
My target is this function:
var DragDropManager = {
dragged: null,
droppable: null,
draggedMatchesTarget: function() {
if (!this.droppable) return false;
return (colSet[this.droppable].indexOf(this.dragged) >= 0);
}
}