Dynamically set items in perspective

Hi guys,

Possible to set dynamic items in perspective flex repeater or any other options?

In my case set instances dynamically and also set instances per row dynamically (get from the database). Here is how many instances set in a per row get from the database. Is it possible in perspective and how?

Any idea?

For more information see below examples:

1. Here is a total of 36 instances, starting from bottom to top and left to right, and here are the 6 rows and per row 6 instances (here total instance, row, column this information get from database).

image

2. Here is a total of 28 instances, starting from bottom to top and left to right, and here are the 3 rows and per row 10 instances (here total instance, row, column this information get from database).

image

Thanks,
Priyanka

flex can go in reverse direction, you can't really give it a fixed number of columns though...

css has
display:grid which can define column.
you cant really define the display in perspective i think, unless you use the canvas component (or maybe with !important)

if you use grid you'll also need

grid-template-columns: auto auto auto... (repeat auto for each column you have)
grid-auto-flow: dense (or something)
you'll have to look it up

To achieve this you'd have to have a static/unchanging value for the width and height of the "items" (Views). Your Flex Repeater would need to render inside of a Coordinate Container and would need the following settings:

direction: row
wrap: wrap-reverse
width: repeated_view_width * items_per_row
height: repeated_view_height * (total_items / items_per_row)

@cmallonee and @victordcq Thank you so much for your response. I will try.

How to pass an integer value (dynamic) to instances (flex repeater)?

You would supply it as a key as you build the instances. If the instances are bound against a query, the keys should automatically be passed to the View being repeated.

If your query returns rows and you want to use the key of 'x' from the row data, the View being repeated needs to have a param of x, and then you would bind some component property against view.params.x.

To make this:

I made a DynamicItem view with two parameters: IsShown and Display. I added a button, with the text bound to the Display property and visible bound to IsShown.
image

view.json
{
  "custom": {},
  "params": {
    "ColNum": 1,
    "Display": "default",
    "IsShown": 1,
    "RowNum": 1
  },
  "propConfig": {
    "params.ColNum": {
      "paramDirection": "input",
      "persistent": true
    },
    "params.Display": {
      "paramDirection": "input",
      "persistent": true
    },
    "params.IsShown": {
      "paramDirection": "input",
      "persistent": true
    },
    "params.RowNum": {
      "paramDirection": "input",
      "persistent": true
    }
  },
  "props": {
    "defaultSize": {
      "height": 81,
      "width": 106
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "Button"
        },
        "position": {
          "height": 55,
          "width": 80,
          "x": 15,
          "y": 12
        },
        "propConfig": {
          "meta.visible": {
            "binding": {
              "config": {
                "path": "view.params.IsShown"
              },
              "type": "property"
            }
          },
          "props.text": {
            "binding": {
              "config": {
                "path": "view.params.Display"
              },
              "type": "property"
            }
          }
        },
        "type": "ia.input.button"
      }
    ],
    "meta": {
      "name": "root"
    },
    "type": "ia.container.coord"
  }
}

I made view named DynamicFlexRow with one parameter RowNum. I added a flex repeater and made the path DynamicItem. I bound the instances to a named query that returns Display and IsShown for all items that are shown on the RowNum.

view.json
{
  "custom": {},
  "params": {
    "RowNum": 1
  },
  "propConfig": {
    "params.RowNum": {
      "paramDirection": "input",
      "persistent": true
    }
  },
  "props": {
    "defaultSize": {
      "height": 98,
      "width": 857
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "FlexRepeater"
        },
        "position": {
          "basis": "98px"
        },
        "propConfig": {
          "props.instances": {
            "binding": {
              "config": {
                "parameters": {
                  "RowNum": "{view.params.RowNum}"
                },
                "queryPath": "DynamicRowInfo",
                "returnFormat": "json"
              },
              "type": "query"
            }
          }
        },
        "props": {
          "path": "Page/Embedded/DyamicItem"
        },
        "type": "ia.display.flex-repeater"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "direction": "column"
    },
    "type": "ia.container.flex"
  }
}
Query ``` SELECT RowNum, ColNum, CHAR(RowNum-1+ASCII('A'))+CONVERT(VARCHAR(2),colnum) as Display, IsShown FROM DynamicGridDefinition WHERE RowNum = :RowNum AND IsShown = 1 ```

Then I created a view with a flex repeater. The path is to the DyanmicFlexRow and the instances property is bound to a query that returns the row number for each row that is shown.

view.json
{
  "custom": {},
  "params": {},
  "propConfig": {
    "params.feature": {
      "paramDirection": "input"
    },
    "params.key": {
      "paramDirection": "input"
    },
    "params.tier1": {
      "paramDirection": "input"
    },
    "params.tier2": {
      "paramDirection": "input"
    }
  },
  "props": {
    "defaultSize": {
      "width": 886
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "Title"
        },
        "position": {
          "basis": "56px",
          "shrink": 0
        },
        "props": {
          "params": {
            "icon": "home",
            "text": "Home"
          },
          "path": "Page/Embedded/Title"
        },
        "type": "ia.display.view"
      },
      {
        "meta": {
          "hasDelegate": true,
          "name": "Spacer_1"
        },
        "position": {
          "basis": "12px",
          "shrink": 0
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "hasDelegate": true,
          "name": "Welcome"
        },
        "position": {
          "basis": "20px",
          "shrink": 0
        },
        "props": {
          "style": {
            "classes": "Page/Bold Page/Margins Page/Text"
          },
          "text": "Dynamic Grid Test - Flex Repeater of Rows"
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "hasDelegate": true,
          "name": "Spacer_2"
        },
        "position": {
          "basis": "10px",
          "shrink": 0
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "hasDelegate": true,
          "name": "Description"
        },
        "position": {
          "shrink": 0
        },
        "props": {
          "style": {
            "classes": "Page/Text Page/Margins"
          },
          "text": "Flex repeater of rows of flex repeaters"
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "hasDelegate": true,
          "name": "Spacer_3"
        },
        "position": {
          "basis": "10px",
          "shrink": 0
        },
        "type": "ia.display.label"
      },
      {
        "children": [
          {
            "meta": {
              "name": "FlexRepeater"
            },
            "position": {
              "basis": "200px",
              "grow": 1
            },
            "propConfig": {
              "props.instances": {
                "binding": {
                  "config": {
                    "queryPath": "DynamicRowCount",
                    "returnFormat": "json"
                  },
                  "type": "query"
                }
              }
            },
            "props": {
              "direction": "column-reverse",
              "elementPosition": {
                "basis": "100px",
                "shrink": 0
              },
              "path": "Page/Embedded/DynamicFlexRow"
            },
            "type": "ia.display.flex-repeater"
          }
        ],
        "meta": {
          "name": "FlexContainer"
        },
        "position": {
          "basis": "100px",
          "grow": 1,
          "shrink": 0
        },
        "props": {
          "direction": "column"
        },
        "type": "ia.container.flex"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "direction": "column",
      "style": {
        "classes": "Page/Page"
      }
    },
    "type": "ia.container.flex"
  }
}
Query ``` SELECT DISTINCT RowNum, IsShown FROM DynamicGridDefinition WHERE IsShown = 1 ```

The actual table is a pegboard instead of the one you defined. It contains a record for each row and column. Note that my query generates the button text based on row/column instead of using the DisplayText because that was easier to test with.
image

The behavior is credible.
Three rows of four:

Smaller browser window:

Six rows of seven:

@Tim_Carlton Thank you so much. Please could you share a backup?

@Tim_Carlton How does your example look if entries in the middle of a row are set to not display? Are there gaps or do the later entries shift to fill the gap?

You don't need a backup. You just need the JSON for the view.

The posted one does not leave gaps:

If a whole row is not shown then there is a gap for the row, which surprises me a bit. I left the IsShown property in case I needed it - maybe can bind it somewhere.


If a whole row is not shown I an save and update everything everywhere then the gap for the row is closed:

An early version does, but it is a lot of hardcoded stuff:

1 Like