Hello,
now I would try the new IG jQuery tools, but I have a problem with the grid. I want to bind a JSON response string from a php service to the grid. But the grid does'nt show any data an add a column that I never defined in the code.
$(function () { $("#grid1").igGrid({ columns: [ { headerText: "ID", key: "id", dataType: "number" }, { headerText: "Description", key: "description", dataType: "string" }, { headerText: "Title", key: "title", dataType: "string" }, ], width: '800px', dataSource: "json_server.php" }); });
Is it possible to bind the return of "json_server.php" to dataSource?
Thanx
Markus
hey Markus,
Thanks for your feedback. Your code snippet is perfectly fine and should work out of the box. The grid uses the data source control internally, so you don't need to configure it manually by yourself, and only then passing an instance of it. Several things i can suggest, that can help you locate the issue:
1) is the json data located directly in the root of the response? If not, you'd probably need to specify a responseDataKey. if you can show me the format of your response i can give you more details on this
2) is the grid generating a request to your json_server.php, and is it returning with code 200 ? You can easily check this by checking with tools such as Firebug's Net tab.
3) do the column types match, meaning that is the ID column indeed a number, etc. ?
Thanks again,
Angel
thank you for your answer. Here is the response of "json_server.php".
{"passwords":[[{"id":1,"description":"test 1","title":"test 1"}],[{"id":2,"description":"test 2","title":"test 2"}]]}
The data are from a mysql query and via PHP jason_encode generated.
Greetz
hi Markus,
if you set the responseDataKey: "passwords" in the options, everything should work fine. but i can see from your response that you are wrapping every object in a separate array, which shouldn't be done. The response should be (I believe):
{"passwords":[{"id":1,"description":"test 1","title":"test 1"},{"id":2,"description":"test 2","title":"test 2"}]}
Hey Angel,
you're right. Twice ;)!
Now, with the responseDataKey and a the new format of the response, I've got the right result..nearly.
I still have one column to much.
Did you have any idea?
Hi Angel,
the autoGenerateColumns is the solution. But I don't know what happens with the last column. I took your json string and put it back to the client. That's all. nothing more. Just wondering.
hm, not sure why this is happening. Could it be that your response contains more columns than what's in every password object? You could also try setting autoGenerateColumns: false, so that only data that is defined in your columns collection gets bound.
Hope it helps,