I'm testing metawidget by creating a demo but having some issues with it. I'm trying to generate a couple of sections and show them by Jquery UI tabs. I could do it with tiny objects, however my object has 250 fields and it generates multiple sections (which is correct) but the problem is that it generates also multiple repeated sections with the same name. For instance:
CMS|Flags|Other|CMS|Flags|Other|CMS|Flags|Other|CMS|Flags|Other|CMS|Flags|Other
I just want:
CMS|Flags|Other|
Do you know why is happening this or how can I fix it?
Thanks a lot.
Federico
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you send a small example project to support@metawidget.org?
At a guess, though: are you putting 'section' attributes on each of your fields? This is not necessary, you only have to put them on the fields where the section changes. However, it's okay to do provided you are also sorting your fields such that you don't keep swapping back/forth between sections. You can sort your fields either by a) the natural order they appear in the JSON; b) explicitly using a 'propertyOrder' attribute.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At the beginning I put section attributes on some fields but noticed that lots of fields were added automatically so my sections which I didn't want. So, then I added more sections and wanted to put all the remaining fields in a 'Other' section, although this didn't solve my problem either.
I have started with a hardcoded object, however the webservices returning the object does not ensure order, that's why I wanted to explicitly set tabs for all of them.
I have sent the html sample to the email you provided above.
Federico
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are a few different (and conflicting) points I need to make here:
You have put your PropertyTypeInspector first in your CompositeInspector. This means it will be dictating the order of the returned fields (based on the natural ordering of the 'toInspect' object). You should probably put it second, after your custom Inspector, so that it just 'fills in' the property types, without dictating the ordering
Your custom inspector is basically returning a JSON Schema, so you should use JsonSchemaInspector instead. Doing it your way, you'll have to check the 'names' array passed in to the function. If Metawidget is asking to inspect anything other than the root of the object (i.e. 'names' is not empty) you'll have to return an empty inspection result, or else you'll get an infinite loop. But JsonSchemaInspector takes care of this little detail for you.
It's fine to explicitly set sections. But you must explicitly set order too, or else the natural ordering of the properties may jump back/forth between sections, and you'll end up with multiple tabs
It sounds like explicitly setting sections is going to be cumbersome for you. If your webservices are returning abitrary objects, you'll want to keep your UI as arbitrary as possible. Therefore you might be better off using an InspectionResultProcessor to process the inspection result, rather than a custom Inspector to produce the inspection result. Then you can attach sections and sort fields without knowing much about what data is returned.
Thanks a lot for the comments, I've based on the "1.2 Part 1" examples to come up with that sample. I have to dig deeper in your explanation because I'm studying this.
For the example you displayed, it gathers the fields by the names, however I need specific fields to be set in specific sections and all the remaining fields to be set in "Others".
Can you send over a link to the inspectors documentation where I can find more information like what you stated the JsonSchemaInspector ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The example I sent can easily be modified to assign different sections to different fields, based on each field's name/type/other metadata. I did a few versions in there for you, but you should be able to modify to suit your needs?
For JsonSchemaInspector, see 4.2.4 JsonSchemaInspector (JavaScript version):
Hello guys,
I'm testing metawidget by creating a demo but having some issues with it. I'm trying to generate a couple of sections and show them by Jquery UI tabs. I could do it with tiny objects, however my object has 250 fields and it generates multiple sections (which is correct) but the problem is that it generates also multiple repeated sections with the same name. For instance:
CMS|Flags|Other|CMS|Flags|Other|CMS|Flags|Other|CMS|Flags|Other|CMS|Flags|Other
I just want:
CMS|Flags|Other|
Do you know why is happening this or how can I fix it?
Thanks a lot.
Federico
Can you send a small example project to support@metawidget.org?
At a guess, though: are you putting 'section' attributes on each of your fields? This is not necessary, you only have to put them on the fields where the section changes. However, it's okay to do provided you are also sorting your fields such that you don't keep swapping back/forth between sections. You can sort your fields either by a) the natural order they appear in the JSON; b) explicitly using a 'propertyOrder' attribute.
Hi Kennard,
At the beginning I put section attributes on some fields but noticed that lots of fields were added automatically so my sections which I didn't want. So, then I added more sections and wanted to put all the remaining fields in a 'Other' section, although this didn't solve my problem either.
I have started with a hardcoded object, however the webservices returning the object does not ensure order, that's why I wanted to explicitly set tabs for all of them.
I have sent the html sample to the email you provided above.
Federico
There are a few different (and conflicting) points I need to make here:
You have put your PropertyTypeInspector first in your CompositeInspector. This means it will be dictating the order of the returned fields (based on the natural ordering of the 'toInspect' object). You should probably put it second, after your custom Inspector, so that it just 'fills in' the property types, without dictating the ordering
Your custom inspector is basically returning a JSON Schema, so you should use JsonSchemaInspector instead. Doing it your way, you'll have to check the 'names' array passed in to the function. If Metawidget is asking to inspect anything other than the root of the object (i.e. 'names' is not empty) you'll have to return an empty inspection result, or else you'll get an infinite loop. But JsonSchemaInspector takes care of this little detail for you.
It's fine to explicitly set sections. But you must explicitly set order too, or else the natural ordering of the properties may jump back/forth between sections, and you'll end up with multiple tabs
It sounds like explicitly setting sections is going to be cumbersome for you. If your webservices are returning abitrary objects, you'll want to keep your UI as arbitrary as possible. Therefore you might be better off using an InspectionResultProcessor to process the inspection result, rather than a custom Inspector to produce the inspection result. Then you can attach sections and sort fields without knowing much about what data is returned.
Kennard,
Thanks a lot for the comments, I've based on the "1.2 Part 1" examples to come up with that sample. I have to dig deeper in your explanation because I'm studying this.
For the example you displayed, it gathers the fields by the names, however I need specific fields to be set in specific sections and all the remaining fields to be set in "Others".
Can you send over a link to the inspectors documentation where I can find more information like what you stated the JsonSchemaInspector ?
The example I sent can easily be modified to assign different sections to different fields, based on each field's name/type/other metadata. I did a few versions in there for you, but you should be able to modify to suit your needs?
For JsonSchemaInspector, see 4.2.4 JsonSchemaInspector (JavaScript version):
http://metawidget.org/doc/reference/en/html/ch04s02.html
Wonderful, I'll continue doing testing with your suggestions.
Thanks, you rock!