webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

Bug in processJSON(), and a fix. #43

Closed dougmc0 closed 10 years ago

dougmc0 commented 10 years ago

So, looking at this demo --

http://www.editablegrid.net/editablegrid/examples/json/index.html

it all works fine. However, it seems to work fine only because of the way the sample data was set up. In particular, part of grid.json looks like this --

    {"id":1, "values":{"country":"uk","age":33,"name":"Duke","firstname":"Patience","height":1.842,"email":"patience.duke@gmail.com","lastvisit":"11\/12\/2002"}},
    {"id":2, "values":["Rogers","Denise",59,1.627,"us","rogers.d@gmail.com","","07\/05\/2003"]},

processJSON() allows you to specify data either as a list of columns or as an associative array. Looks like the sample data was given this way so we can see both methods. (Very nice.)

However, the list of columns only works as long as an associative array had been processed previously.

If the first data point processed is a list of columns, you get a

"Uncaught ReferenceError: cellValues is not defined"

error.

The fix seems quite simple. In editablegrid.js, add this line --

            var cellValues = {};

before this line

            // row values can be given as an array (same order as columns) or as an object (associative array)^M
dougmc0 commented 10 years ago

Should have checked out the git repository first -- seems the fix has already been made.

Cheers!