Autodesk setreference for child assemblies not working - autodesk

I am having trouble referencing child assemblies that are required for a parent assembly translation.
First I POST to https://developer.api.autodesk.com/references/v1/setreference with the following body
{ master: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam',
dependencies:
[ { file: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-e3l7hokp0qxqn227b7qcjo47vi.iam',
metadata:
{ childPath: 'fuselage.iam',
parentPath: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam' } },
{ file: 'urn:adsk.objects:os.object:stemn/57b9f339c77fe2652f830206-mhrb7um0of74iasv37nzh0k9.iam',
metadata:
{ childPath: 'motor_mount.iam',
parentPath: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam' } } ] }
After setting references, I request translation and get the following result of the translation:
{ Result: 'Success',
Scope: '25660970-8194-4de0-baa4-c8f1f132b2a7',
RegisterType: [ 'thumbnail', '2dviewing', '3dviewing' ] }
After that I get the manifest for the urn and it is as follows:
{ guid: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
owner: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
type: 'design',
hasThumbnail: 'false',
startedAt: 'Wed Jan 04 04:43:59 UTC 2017',
urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
region: 'US',
status: 'failed',
progress: 'complete',
success: '100%',
children:
[ { guid: 'aa85aad6-c480-4a35-9cbf-4cf5994a25ba',
messages:
[ { type: 'warning',
message: 'The drawing\'s thumbnails were not properly created.',
code: 'TranslationWorker-ThumbnailGenerationFailed' } ],
name: '57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.iam',
success: '100%',
hasThumbnail: 'false',
role: 'viewable',
version: '2.0',
urn: 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt',
status: 'failed',
assetCount: 25,
type: 'folder',
progress: 'complete',
children:
[ { guid: '015896d9-e6d3-4be6-8f3d-96da5e64eed3',
type: 'folder',
name: 'Scenes',
status: 'success',
progress: 'complete',
success: '100%',
hasThumbnail: 'false',
children:
[ { guid: '451f7aab-1917-40dd-b117-5dd8f90ab6a7',
type: 'geometry',
role: '3d',
name: 'Scene',
status: 'success',
messages:
[ { type: 'warning',
code: 'ATF-1023',
message:
[ 'The file: {0} does not exist.',
'X:\\Google Drive\\SCAAD\\PRJ_HAARDCraft\\HAARDCraft_JFlight\\CAD\\Fuselage\\fuselage.iam' ] },
{ type: 'warning',
code: 'ATF-1023',
message:
[ 'The file: {0} does not exist.',
'X:\\Google Drive\\SCAAD\\PRJ_HAARDCraft\\HAARDCraft_JFlight\\CAD\\Engine mount\\motor_mount.iam' ] },
{ type: 'error',
code: 'ATF-1026',
message:
[ 'The file: {0} is empty.',
'C:/worker/viewing-inventor-lmv/tmp/job-1/68/output/1/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.svf' ] } ],
size: 27864,
progress: 'complete',
success: '100%',
hasThumbnail: 'false',
children:
[ { guid: '6dc4b244-8a47-4a75-bcb3-811dc7b4f294',
type: 'resource',
urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/1/57b9f339c77fe2652f830206-ckwdob3791d6u359wz7eklnmi.svf',
role: 'graphics',
mime: 'application/autodesk-svf',
size: 27864 } ] },
{ guid: '9bb1adbe-d9d9-4482-ac03-1d60bb0aea36',
type: 'resource',
urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/1/properties.db',
role: 'Autodesk.CloudPlatform.PropertyDatabase',
mime: 'application/autodesk-db',
status: 'success',
size: 24576 } ] },
{ guid: '039c2bcf-beb7-426b-916c-4a5adb814593',
type: 'resource',
role: 'Autodesk.CloudPlatform.DesignDescription',
urn: 'urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTdiOWYzMzljNzdmZTI2NTJmODMwMjA2LWNrd2RvYjM3OTFkNnUzNTl3ejdla2xubWkuaWFt/output/xref/designDescription.json',
mime: 'application/json' } ] } ] }
Using the same code path I can successfully render an assembly with non-assembly child parts that have been set using setreference, but when rendering an assembly with child assemblies, setreference doesn't seem to set the references to the child assembly files successfully. Is there something wrong in my sequence for setting references to child assemblies?

I discussed with #sabrehage and finally got the working codes.
firstly, it is recommended to use Forge Derivative API v2 (zip + specify root file only), by which, the API user does not need to specify the references explicitly.
If you still want to use Forge Derivative API v1, the following is the note:
In local Inventor, the file references are managed by Inventor Project. Inventor will look for the ref files firstly in the specific folders of the Project, then look for the relative paths. Obviously, when the files are uploaded to bucket of Forge, no project file, all files are in the same level in physical perspective. So in v1, it depends on the reference file that the sender specifies.
If the hierarchy is like:
Top Assembly.iam
part1.ipt
part2.ipt
The reference file can be simply composed like what is mentioned in the blog:
http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html.
In the dataset of #sabrehagen, the hierarchy contains nested assemblies, even in sub folder:
topassemb.iam
part in top assemb.ipt
subassem folder
subassem.iam
part1 in sub assem1.ipt
part2 in sub assem1.ipt
The correct way is to specify in one call (for top assembly only), and specify the subfolder in the reference map. In addition, we should define path name with original name, instead of that has been URL encoded. i.e.
{
"master" : "urn:adsk.objects:os.object:adsk2017-8/topassemb.iam",
"dependencies" : [
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/subassem.iam",
"metadata" : {
"childPath" : "subassem/subassem.iam",
"parentPath" : "topassemb.iam"
}
},
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/part1%20in%20sub%20assem1.ipt",
"metadata" : {
"childPath" : "part1 in sub assem1.ipt",
"parentPath" : "subassem/subassem.iam"
}
},
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/part2%20in%20sub%20assem1.ipt",
"metadata" : {
"childPath" : "part2 in sub assem1.ipt",
"parentPath" : "subassem/subassem.iam"
}
},
{
"file" : "urn:adsk.objects:os.object:adsk2017-8/part%20in%20top%20assemb.ipt",
"metadata" : {
"childPath" : "part in top assemb.ipt",
"parentPath" : "topassemb.iam"
}
}
]
}
If without specifying subfolder, Forge thinks all files are within the same level, but it conflicts to the hierarchy of the last saving (absolute path). So it failed to find the corresponding files in the bucket.
After Forge gets the files and correct reference, it will look at the reference file and create the subfolders if they are specified, then put those files to the subfolder from bucket, finally translate.

as I remember, you would also need to configure the parts in the web service of set reference. This is a blog: http://adndevblog.typepad.com/cloud_and_mobile/2015/09/how-to-set-references-with-inventor-files-for-view-and-data-api.html. probably it could help you to diagnose the issue.
But, I strongly suggest you migrate to v2, by which you do not need to set reference manually. you can just upload all dataset as a zip file and set which file is the top (root) file, Forge will analyze the hierarchy automatically. This is another blog: http://adndevblog.typepad.com/cloud_and_mobile/2016/07/translate-referenced-files-by-derivative-api.html

Related

Shared Views + Forge access - Can I push an Inventor model as a shared view and then access the bucket in a forge app

I would like to use the Shared Views feature of Vault/AutoCAD/ACADE/Inventor to push models and such (in particular larger Inventor assemblies) up to the cloud, where I assume they land in an OSS bucket. I think that they are only valid up there for 30 days, but that length of time is fine for my purpose. What I would like to know is there any way I can get the ID of the bucket, and then use that to view or pull that SVF file into an APP back inside my firewall for further use? I have some extensions planned in a viewer app back on premises, but I don't have a good way to get the models into the cloud and generated in the first place because of the references in the model - I would have to checkout the model and all references, zip them up, and then send it to the model derivative and such. I am hoping that since the shared views feature already does that part, I can just leverage that to start my process.
MORE INFO:
So, using Fiddler I can see several interesting calls related to this. I went into Vault and created a shared view for a DWG file, then just watched the traffic. I see calls in a pattern that could be maybe leveraged.
Call 1:
GET https://360.autodesk.com/Viewer/GetViewerTranslationById?viewerId=dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u
Call 2:
GET https://360.autodesk.com/Viewer/GetAccessToken
Call 2 returns a token:
token_type: "Bearer"
expires_in: "3599"
expires_at: "2020-07-17T17:02:15.1187374+00:00"
access_token: "eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJzY29wZSI6WyJkYXRhOnJlYWQiLCJkYXRhOndyaXRlIiwiZGF0YTpzZWFyY2giXSwiY2xpZW50X2lkIjoiVmZNQ3U1NDg2U3hLQXVRaGRVMU9aYTJuTHdqR1VXcEciLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwNjAiLCJqdGkiOiI5NVFQYnhGWjlmZ1p0YWxzbXg2OW1oUWczck9WbWRKeDRtZjdtdUY0Z0xBME01TmNqZjJCT1hoa3RiRHdlVm04IiwiZXhwIjoxNTk1MDA1MzQ2fQ.tRQYz7PP-_NIDrZFrWbXvxiP4NfooBHAIC89eQuelkw"
bucket: "a360viewer"
Then Call 3 to the derivatives service:
GET https://developer.api.autodesk.com/derivativeservice/v2/manifest/dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u
.....
Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJzY29wZSI6WyJkYXRhOnJlYWQiLCJkYXRhOndyaXRlIiwiZGF0YTpzZWFyY2giXSwiY2xpZW50X2lkIjoiVmZNQ3U1NDg2U3hLQXVRaGRVMU9aYTJuTHdqR1VXcEciLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwNjAiLCJqdGkiOiI5NVFQYnhGWjlmZ1p0YWxzbXg2OW1oUWczck9WbWRKeDRtZjdtdUY0Z0xBME01TmNqZjJCT1hoa3RiRHdlVm04IiwiZXhwIjoxNTk1MDA1MzQ2fQ.tRQYz7PP-_NIDrZFrWbXvxiP4NfooBHAIC89eQuelkw
....
Call 3 returns lots of information:
guid: "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u"
owner: "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u"
hasThumbnail: "true"
startedAt: "Fri Jul 17 16:06:29 UTC 2020"
type: "design"
urn: "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u"
success: "100%"
progress: "complete"
region: "US"
status: "success"
children:
0:
guid: "aa85aad6-c480-4a35-9cbf-4cf5994a25ba"
hasThumbnail: "true"
role: "viewable"
progress: "complete"
type: "folder"
status: "success"
version: "2.0"
urn: "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u"
inputFileSize: 1059328
inputFileType: "collaboration"
name: "C-424305-036.dwg.dwf"
success: "100%"
children:
0:
guid: "87CBE465-EAB2-43C0-BA0A-D148B3418FF3_Sheets"
type: "folder"
name: "Sheets"
hasThumbnail: "true"
status: "success"
progress: "complete"
success: "100%"
children:
0:
guid: "933b32f8-830d-4861-6e81-294f5d07d4fc"
type: "geometry"
role: "2d"
name: "C-424305-036-Model"
status: "success"
size: 585718
hasThumbnail: "true"
progress: "complete"
success: "100%"
viewableID: "com.autodesk.dwf.ePlot_87CBE466-EAB2-43C0-BA0A-D148B3418FF3"
order: 0
children:
0:
urn: "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u/output/933b32f8-830d-4861-6e81-294f5d07d4fc_f2d/primaryGraphics.f2d"
role: "graphics"
size: 503288
mime: "application/autodesk-f2d"
guid: "c7624064-cb61-933b-787c-e02bef313ea4"
type: "resource"
status: "success"
1:
urn: "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u/output/933b32f8-830d-4861-6e81-294f5d07d4fc_f2d/section_properties.db"
role: "Autodesk.CloudPlatform.PropertyDatabase"
size: 24576
mime: "application/autodesk-db"
guid: "20392091-d0da-d74d-741f-904b078b9c0a"
type: "resource"
status: "success"
2:
guid: "a3a9ad7f-b9aa-451e-8bbc-da2972137d82"
type: "view"
role: "2d"
name: "INITIAL"
viewbox:
0: 0.67
1: 0.575
2: 16.330833
3: 10.423333
1:
guid: "d6e600db-d158-d84f-3101-0a654aa29df3"
type: "geometry"
role: "2d"
name: "C-424305-036-C-424305-036-00"
status: "success"
size: 617457
hasThumbnail: "true"
progress: "complete"
success: "100%"
viewableID: "com.autodesk.dwf.ePlot_87CBE467-EAB2-43C0-BA0A-D148B3418FF3"
order: 1
children:
0:
urn: "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u/output/d6e600db-d158-d84f-3101-0a654aa29df3_f2d/primaryGraphics.f2d"
role: "graphics"
size: 535065
mime: "application/autodesk-f2d"
guid: "441471cc-a249-1b4e-36dd-7ea4bff584cd"
type: "resource"
status: "success"
1:
urn: "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6YTM2MHZpZXdlci90NjM3MzA1OTg3ODExMjQxMTQ4XzQxYjE3M2M1LTVmZjctNDQ2ZC1iNTFkLTgwZTg1NjQ3NjU3ZC5jb2xsYWJvcmF0aW9u/output/d6e600db-d158-d84f-3101-0a654aa29df3_f2d/section_properties.db"
role: "Autodesk.CloudPlatform.PropertyDatabase"
size: 24576
mime: "application/autodesk-db"
guid: "03334fbb-15ce-446d-ff80-111dc8616642"
type: "resource"
status: "success"
2:
guid: "69f50589-0774-4cf3-9b21-8164c1e71027"
type: "view"
role: "2d"
name: "INITIAL"
viewbox:
0: 3.958333
1: 0.4325
2: 16.330833
3: 10.565
Further research reveals that the ID used for calling is base64 encoded, decoding it reveals this:
urn:adsk.objects:os.object:a360viewer/t637305987811241148_41b173c5-5ff7-446d-b51d-80e85647657d.collaboration

ExtJS REST store: sync() doesn't remove records on the server

I use ExtJS 4.2.2. A store for browsing and managing folders is defined like this:
Ext.define('hds.store.CaseFolders', {
extend: 'Ext.data.Store',
requires: [
'app.model.Folder',
'Ext.data.proxy.Rest',
'Ext.data.reader.Json',
'Ext.data.writer.Json'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: false,
model: 'app.model.Folder',
storeId: 'Folders',
proxy: {
type: 'rest',
url: '/api/folders.json',
reader: {
type: 'json',
messageProperty: 'message',
root: 'data'
},
writer: {
type: 'json',
writeAllFields: false,
root: 'data'
}
}
}, cfg)]);
}
});
It uses this model:
Ext.define('app.model.Folder', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.Field'
],
fields: [
{
name: 'name',
type: 'string'
},
{
name: 'parentId',
type: 'int'
},
{
name: 'type',
type: 'string'
}
]
});
Folders can be added, renamed and removed.
When changing the name of the folder, for example and using store.sync(), the record is properly synced to the server with a PUT containing id and name attributes.
However, when deleting the folder, store.sync() doesn't send any request to the server. A callback function was added to sync, but it is not called at all.
It seems that the REST store (proxy?) "thinks" that there is nothing to sync to the server.
Why is it like that?
Found the reason for the problem that I had:
The store is filtered to show content of the folder to be deleted.
When wanting to delete current folder, its record is filtered away.
Adding a line to remove filters before removing the parent folder record solved the problem.

Extjs 4 - create new empty Record from Store without Model

I have tried to create a new empty record without creating a model.
Accidentally I tried to run this:
new new storeComp.model()
and it actually works!
anyone know any solution for this or an answer to how is it working ?
Thanks!
Shalev
Stores that are not configured with a model will create an anonymous one implicitly. This is explained in the docs for the implicitModel private property (the store needs to know that because if it uses an implicit model, it must destroy it when it is itself destroyed).
In the end that means that you can safely expect any store to be backed with a model.
I faced the same problem for an associative store. For that i have used below JSON format to load project store. So automatically empty record is created in associative (project-resources) Store.
Store:
Ext.define('App.store.Projects', {
extend : 'Ext.data.Store',
model : 'App.model.Project'
});
Models:
Ext.define("App.model.Project", {
extend: 'Ext.data.Model',
idProperty : 'id',
uses : ['App.model.ProjectResource'],
fields: [
{ type: 'auto', name: 'id'},
{ type: 'number', name: 'customerid'},
{ type: 'string', name: 'projectcode'}
],
associations: [
{type: 'hasMany', model: 'App.model.ProjectResource', name: 'Resources', storeConfig: { remoteFilter: true }}
]
});
Ext.define("App.model.ProjectResource", {
extend: 'Ext.data.Model',
idProperty : 'id',
fields: [
{ type: 'number', name: 'id'},
{ type: 'string', name: 'name'},
{ type: 'number', name: 'projectid'},
{ type: 'auto', name: 'resourceid'}
],
associations : [
{type : 'belongsTo', model: 'App.model.Project'}
]
});
JSON Format:
[
{
"id": "105",
"customerid": "105",
"projectcode": "ALN01",
"Resources": {}
}
]
Loading store with empty object (like "Resources": {}) will create empty model.

Load static JSON data from URL for ExtJS grid panel

I tried to implement a grid panel using data from a JSON file which is located on the same domain as the Javascript file containing the ExtJs code. I'm using ExtJs 3.4.
The grid shows up but without any data in it. Firebug shows an error message that tells me that there is an error in the first line of the JSON file ("not well formed"). I have validated the JSON file and everything is ok.
Here is my code:
Ext.onReady(function () {
var myStore = new Ext.data.JsonStore({
url: 'data.json',
root: 'rows',
autoLoad: true,
fields: [{
name: 'person',
type: 'string'
}, {
name: 'product',
type: 'string'
}]
});
var grid = new Ext.grid.GridPanel({
id: 'gridPanel',
title: 'Grid example',
width: 250,
height: 250,
renderTo: 'grid-example',
store: myStore,
columns: [{
header: 'Person',
dataIndex: 'person'
}, {
header: 'Product',
dataIndex: 'product'
}]
});
});
My JSON data is:
{
"rows": [{
"person": "Jamie Avins",
"product": "Ladder"
}, {
"person": "Ed Spencer",
"product": "Spanner"
}]
}
Do you have any ideas what's wrong? Can somebody give me some hints?
Thanks in advance!
Seha
Use:
reader: {
type: 'json',
root: 'rows'
}
in your JsonStore and validate your json response.
Hope it will work for you.
I tested your code and the exact JSON string cut and pasted from your example. It worked just fine using Grails to return the string (not reading from a file). Firebug did not complain. Looks like the file itself could be the issue, maybe a hidden character is creeping in.

Ext JS 4 using JSON in proxy reader will not load records

I am trying to use Ext JS 4 and was playing with one of the grid examples and wanted to use JSON rather than XML. No mater how I code the JSON data, I get no records to load.
Here is my code:
Ext.define('Plant', {
extend: 'Ext.data.Model',
fields: [{
name: 'common',
type: 'string'
}, {
name: 'botanical',
type: 'string'
}, {
name: 'light'
}, ]
});
// Create the Data Store.
var store = Ext.create('Ext.data.Store', {
// Destroy the store if the grid is destroyed.
autoDestroy: true,
model: 'Plant',
proxy: {
type: 'ajax',
url: 'plants.json',
reader: {
type: 'json',
root: 'records'
}
},
sorters: [{
property: 'common',
direction: 'ASC'
}]
});
Here is my data:
{
"records": [
{
"common": "Bloodroot",
"botanical": "Sanguinaria canadensis",
"light": "Mostly Shady"
}, {
"common": "test",
"botanical": "I do not know",
"light": "Mostly Shady"
}
]
}
The XML reader works great, but we want to use JSON.
Thanks in advance
Have a look at this thread! You need to check your url path to plants.json, path starts from 'index.html' or some other similar starting point , and not the .js file where store is located. I tested your code and it works fine, also use autoLoad:true in your Ext.data.Store, i dont see your grid code so.. Cheers!