Skip to content

Data Input Formats

adlevsky edited this page Apr 12, 2018 · 30 revisions

1. HTML String / JQuery Node / HTML Elements

Input should be formatted like so:

<ul>
    <li name="Item 1" searchable="search me" selected="false">
    <img src="path/image.png">
    <ul>
        <li name="Item 1.1" value="1.1" searchable="search me" selected="false">
            <i class="fa faIcon"></i>
        </li>
        <li name="Item 1.2" searchable="search me" selected="false" data-img="path/image.png"><ul>
            <li name="Item 1.2.1" value="1.2.1" searchable="search me" selected="false" data-icon="fa faIconClass"></li>    
        </ul></li>
    </ul></li>
    <li name="Item 2" value="2" searchable="search me" selected="false"></li>  
</ul>

This can be input in either and HTML string, pure HTML elements, or a JQuery HTML list

Things to keep in mind:

  1. String HTML should be input using the data-load-type="HTML"
  2. HTML node lists should be input using the data-load-type="liveHTML"
  3. Headers are specified by the <li> followed by <ul> tag
  4. Data is always stored in the <li> tag
  5. Data for headers
    • name: the name displayed for the user
    • searchable: the text that can also be used to match this item
    • selected: if this data item is pre-select (defaults to false)
  6. Data for items
    • value: the value to be retrieved when the user selects this item
    • name: the name displayed for the user
    • searchable: the text that can also be used to match this item
    • selected: if this data item is pre-select (defaults to false)
  7. Importing Images and Icons
    • When importing Images and Icons, Images always take precedence over icons
    • The tag and take precedence ovar the attributes "data-img" and "data-icon"

2. Array Input Data

Format Should be like :

var array = [
                { // a header
                    "name": "Item1",
                    "searchable": "Item1",
                    "selected": false,
                    "icon": "fa faIconClass" // icon classes to be added to the item
                    "items": [
                        { // list of items 
                            "name": "Item1.1",
                            "searchable": "Item1.1",
                            "selected": false,
                            "value" : "1.1",
                            "image": "Path/Image2" // and image to be displayed
                        },
                        { // item 1.2 is also a header 
                            "name": "Item1.2",
                            "searchable": "Item1.2",
                            "selected": false,
                            "items" : [            
                                   {  // list of items for 1.2
                                       "name": "Item1.2.1",
                                       "searchable": "Item1.2.1",
                                       "selected": false,
                                       "value" : "1.2.1"
                                   },
                                   {
                                    "name": "Item1.2.2",
                                       "searchable": "Item1.2.2",
                                      "selected": false,  
                                      "value" : "1.2.2" 
                                   }
                                      ]
                        }      ]      
                },      ];

Example: Array = [ {Item1 [{Item1.1} , {Item1.2 [ {Item 1.2.1}] } ]}, {Item 2}]

Things to keep in mind:

Item 1 , Item 1.2 are headers
Item 1.1, Item 1.2 are items for header "Item 1"
Item 1.2.1 is the item for header "Item 1.2"

  1. Data is always stored in Items within the header
  2. Data for headers
    • name: the name displayed for the user
    • searchable: the text that can also be used to match this item
    • selected: if this data item is pre-select (defaults to false)
  3. Data for items
    • value: the value to be retrieved when the user selects this item
    • name: the name displayed for the user
    • searchable: the text that can also be used to match this item
    • selected: if this data item is pre-select (defaults to false)

3. XML Input

Input should be formatted along the lines of the following:

<data>
     <item>
          <name>Item 1</name>
          <value>Item 1</value>
          <searchable>Item 1</searchable>
          <selected>false</selected>
          <icon>fa faIconClasses</icon> // the classes to be applied to an icon
          <item>
                  <name>Item 1.1</name>
                  <value>Item 1.1</value>
                  <searchable>Item 1.1</searchable>
                  <selected>false</selected>
                  <image>Path/ToImage3</image> // a path to an image for this item
          </item>
          <item>
                  <name>Item 1.2</name>
                  <searchable>Item 1.2</searchable>
                  <selected>false</selected>
                  <item>
                          <name>Item 1.2.1</name>
                          <value>Item 1.2.1</value>
                          <searchable>Item 1.2.1</searchable>
                          <selected>false</selected>
                  </item>
                  <item>
                          <name>Item 1.2.2</name>
                          <value>Item 1.2.2</value>
                          <searchable>Item 1.2.2</searchable>
                          <selected>false</selected>
                  </item>
          </item>
     </item>
     <item>
          <name>Item 2</name>
          <value>Item 2</value>
          <searchable>Item 2</searchable>
          <selected>false</selected>
     </item>
</data>

Things to keep in mind:

  1. Headers are evidenced by lack of a <value> tag and presence of <subitemX> tags under the <item> or <subitemY> tags.
  2. Data is always specified by the <value> tag
  3. Data for headers:
    • value: The value retrieved when the item is selected
    • name: The name as it will appear in the multiselect
    • searchable: Additional text beyond the name that can be used to search for that specific item
    • selected: Determines whether the item will be pre-selected (false by default)
  4. Data for items and subitems:
    • value: The value retrieved when the item is selected
    • name: The name as it will appear in the multiselect
    • searchable: Additional text beyond the name that can be used to search for that specific item
    • selected: Determines whether the item will be pre-selected (false by default)

4. CSV Input

Input should be formatted like so:

'"h1", "value1", "searchable1", "selected1", "path/to/image", "icon classes"'\n
'"h6", "value2", "searchable2", "selected2", "path/to/image", "icon classes"'\n
'"h1.h2", "value3", "searchable3", "selected3", "path/to/image", "icon classes"'\n
'"h1.h4", "value4", "searchable4", "selected4", "path/to/image", "icon classes"'\n
'"h1.h2.h3", "value5", "searchable5", "selected5", "path/to/image", "icon classes"'\n

Things to keep in mind:

  1. The names of nested items must be formatted in the style of h1.h2.h3, h1.h2.h4, etc.
  2. A new line character is needed to separate the value of different headers/items.
  3. Data for headers/items:
    • value: The value retrieved when the item is selected, inconsequential for headers
    • name: The name as it will appear in the multiselect
    • searchable: Additional text beyond the name that can be used to search for that specific item
    • selected: Determines whether the item will be pre-selected (false by default)
    • path/to/image: The file path to the location of the image for the icon
    • icon classes: Determines the icon for the header/item via icon class

When Importing Images/Icons

  • An Image will always take precedence over and icon class (i.e. both will not be displayed)

5. JSON Input Data

Format Should be like :

var JSONDATA = [
                { // a header
                    "name": "Item1",
                    "searchable": "Item1",
                    "selected": false,
                    "items": [
                        { // list of items 
                            "name": "Item1.1",
                            "searchable": "Item1.1",
                            "selected": false,
                            "value" : "1.1",
                            "image": "Path/Image2" // and image to be displayed
                        },
                        { // item 1.2 is also a header 
                            "name": "Item1.2",
                            "searchable": "Item1.2",
                            "selected": false,
                            "items" : [            
                                   {  // list of items for 1.2
                                       "name": "Item1.2.1",
                                       "searchable": "Item1.2.1",
                                       "selected": false,
                                       "value" : "1.2.1"
                                   },
                                   {
                                    "name": "Item1.2.2",
                                       "searchable": "Item1.2.2",
                                      "selected": false,  
                                      "value" : "1.2.2" 
                                   }
                                      ]
                        }      ]      
                },      ];

Example: JSON = [ {Item1 [{Item1.1} , {Item1.2 [ {Item 1.2.1}] } ]}, {Item 2}]

Things to keep in mind:

Item 1 , Item 1.2 are headers
Item 1.1, Item 1.2 are items for header "Item 1"
Item 1.2.1 is the item for header "Item 1.2"

  1. Data is always stored in Items within the header
  2. Data for headers
    • name: the name displayed for the user
    • searchable: the text that can also be used to match this item
    • selected: if this data item is pre-select (defaults to false)
  3. Data for items
    • value: the value to be retrieved when the user selects this item
    • name: the name displayed for the user
    • searchable: the text that can also be used to match this item
    • selected: if this data item is pre-select (defaults to false)