Commits

Matthew Schinckel committed 4cd8ed4

Prevent cells being given incorrect row header values when new columns created.
Prevent missing cells when creating columns and rows without editing the headers.

Comments (0)

Files changed (1)

jsonfield/static/js/json-table.js

         };
     }
     
+    function getVisibleHeaders($table) {
+        return {
+            rowHeaders: $table.find('th.row-header input.heading-value').map(function(i,x){return x.value}),
+            columnHeaders: $table.find('th.column-header input.heading-value').map(function(i,x){return x.value})            
+        };
+    }
+    
     function inAny(value, arrays){
         // is the value in any of the passed in arrays?
         result = false;
         var label = $table.attr('label');
         $.tmpl('row', {
             row:defaults.defaultRowHeaderValue,
-            headers: getHeaders(data[label]),
+            headers: getVisibleHeaders($table),
             data: data,
             label: label,
             row_id: $table.find('tr.data-row').length
             $.tmpl('cell', {
                 data:{},
                 row_id:i,
-                row:$(el).find('th input').val(),
+                row:$(el).find('th input.heading-value').val(),
                 column_id: column_id,
                 column: column,
                 table: label