Results 1 to 4 of 4

Thread: How do you map an arbitrary JSON structure to a TreeStore to load into a TreeGrid?

  1. #1
    Sencha Premium User
    Join Date
    Jul 2013
    Posts
    24

    Default How do you map an arbitrary JSON structure to a TreeStore to load into a TreeGrid?

    I have a JSON structure that is generated that doesn't make to "object/field" type model.

    It has arbitrary ( as not know before hand ) attributes and types ( types are restricted to String and Array of String ).

    Imagine JSON generated from a Map where the keys aren't constrained to a specific set and the values can be either another Map, String or List<String>.

    How would I go about defining Models and configuring a TreeStore to load and store this type of JSON data?

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    In ExtJS 5 you don't have to define the fields of the model explicitly any longer. Will you at least be returned back the fields you have mapped to the TreeGrid columns using the dataIndex config on the columns or even that will be arbitrary?

  3. #3
    Sencha Premium User
    Join Date
    Jul 2013
    Posts
    24

    Default

    That is kind of the problem, I can't map anything before hand.

    This is a configuration property object that has ad hoc field names, I am trying to create a generic component that every application that uses this configuration framework without having to map things to begin with. Every application will have different objects and attributes in the tree.

    The interface for this configuration system is very closely related to the "Preferences" API in the Java SDK.
    In that it is a Map<String, Object> where Object can be one of the following String, List<String> or Map<String, Object> ( where this Map has the same constraints as the root ).

  4. #4
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    Do you have control over the returned JSON data at least to the point that you could put a metaData key with information in there as to what fields needed to ultimately be mapped to the column / columns of your tree? For example, you normally will map 'text' to the text value of the treecolumn, but if the returned dataset is truly random hopefully you have some way to attach a manifest with it to say what should be displayed in the tree from the dataset?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •