Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export position as json #930

Closed
vhdm opened this issue Aug 1, 2018 · 3 comments
Closed

export position as json #930

vhdm opened this issue Aug 1, 2018 · 3 comments

Comments

@vhdm
Copy link

vhdm commented Aug 1, 2018

@hairyheron
hi,
how to i can export current position as JSON format, then show by this json.

@hairyheron
Copy link
Contributor

I am not a maintainer of this project. Even if I were, I do not understand your question.

@zhanazhan
Copy link

zhanazhan commented Aug 3, 2018

If you want to persist layout of gridstack on the page, here is a short example:

var getGridJSON = function () {
    var nodes = $('#gridstack').data('gridstack').grid.nodes;
    return nodes.map(function(obj, idx){
       return {
           x: obj.x,
           y: obj.y,
           width: obj.width,
           height: obj.height,
           minHeight: obj.minHeight,
           minWidth: obj.minWidth
       }
    });
};
// this will give you array with each gridstack item, stringify it and persist in the backend :)
console.log(getGridJSON());

@radiolips
Copy link
Member

Thanks, @zhanazhan . That looks like a good solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants