Select to view content in your preferred language

Uncaught TypeError: Converting circular structure to JSON peinr

2720
1
03-24-2016 08:43 AM
WeiGao1
Deactivated User

I am using print widget to print map, but receive this error "Uncaught TypeError: Converting circular structure to JSON"

Tags (1)
0 Kudos
1 Reply
ChrisSmith7
Honored Contributor

Hi Wei,

I see this thread has been hanging out for a few months without a reply, so hopefully I'm not too late...

I recently encountered this myself and discovered a resolution. In my particular case, I had a dojox datagrid embedded within the mapping application. When the grid became populated with a data store, in this case:

                var data = {
                    identifier: "col_ID", //pk
                    label: "col_label", //display field
                    items: allItems
                };
                //create data store and bind to grid
                store = new ItemFileReadStore({
                    data: data
                });
                var grid = registry.byId("jGrid");
                grid.setStore(store);

...the array allItems created a circular reference in the API print widget JavaScript during jsonification of the map. I resolved it, not so elegantly as it were, by performing a deep clone of the data store's items array. Here's the resolution for me:

                //deep clone original items object
                var newArray = JSON.parse(JSON.stringify(allItems.slice()));
                var data = {
                    identifier: "col_ID", //pk
                    label: "col_label", //display field
                    items: newArray
                };
                //create data store and bind to grid.
                store = new ItemFileReadStore({
                    data: data
                });
                var grid = registry.byId("jGrid");
                grid.setStore(store);

Hope this helps!