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

ajax json data #2

Open
cpolcino opened this issue Mar 14, 2016 · 4 comments
Open

ajax json data #2

cpolcino opened this issue Mar 14, 2016 · 4 comments

Comments

@cpolcino
Copy link

Hi, it is possible to use ajax call to get json data? thanks a lot

@cpolcino cpolcino changed the title Hi, it is possible to use ajax call to get json data? thanks a lot ajax json data Mar 14, 2016
@mydea
Copy link
Owner

mydea commented Mar 14, 2016

The way this is implemented right now is that you would need to load all data before loading the table.

@Rolok
Copy link

Rolok commented Sep 21, 2016

First, off, let me say this makes handsontable gorgeous.

I'm fine with loading all the data before loading the table -- but don't know how to go about doing that.

I've tried using a hard coded variable in place of the values for data: in the chosenOptions, but to no avail. The list of values works fine as a literal string. I've tried putting a variable with just the id and label within the square brackets. I've tried including the square brackets in the variable. I've tried JSON.stringify(test). Is there any way to do this so that at load time I can set a list of values for the value list? I don't want to modify the list during usage, just at load I want to give it the values needed.

@mydea
Copy link
Owner

mydea commented Sep 22, 2016

Doesn't the example from https://github.com/mydea/handsontable-chosen-editor work for you? E.g.:

chosenOptions: {
  data: [
    {
      id: "SPOT",
      label: "Spot"
    }, {
      id: "AFLOAT",
      label: "Afloat"
    }, {
      id: "PREORDER",
      label: "Preorder"
    }
  ]
}

@Rolok
Copy link

Rolok commented Sep 22, 2016

Yes, that example works wonderfully. However, what I was trying to do was to have those values be represented by a variable. Something that could be loaded before everything else and then used.

I worked more with it this morning. My struggle was getting the array of objects together. A simplified final example of my data that worked is here.

var myListOfValuePairs = [{ id:"299", label: "Accent Tables"},{ id:"248", label: "Accessories"}]

chosenOptions: {
multiple: true,
data: myListOfValuePairs

Thank you for responding, and hopefully this helps anybody else that comes along.

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

No branches or pull requests

3 participants