Knockoutjs Recurring Array - asp.net

I am creating a treeview styled object using KnockoutJS and need to be able to have x number of children folders and items. Has anyone done a recurring array on screen, I usually use foreach and I can put one child within another but I can't figure out how to change the template to make them recurring, is it even possible? To clarify I can get the items into knockout fine it's simply getting them displayed on screen.
Looked everywhere on the internet but can only find nested templates rather than recurring ones. Can anyone help?

Let me demonstrate how you can achieve this using a template.
Let suppose you have the following viewmodel:
var comments = [{
id: 1,
comment: 'How can i use knockoutjs?',
childrenLength: 3,
children: [{
id: 2,
comment: 'Please search before asking',
childrenLength: 0,
children: []
}, {
id: 3,
comment: 'Please read the documentation',
childrenLength: 0,
children: []
}, {
id: 4,
comment: 'You can see the blog posts on this',
childrenLength: 2,
children: [{
id: 5,
comment: 'Please search before asking',
childrenLength: 0,
children: []
}, {
id: 6,
comment: 'Please search before asking',
childrenLength: 0,
children: []
}]
}]
}, {
id: 7,
comment: 'You question is not sufficient to be asked here?',
childrenLength: 3,
children: [{
id: 8,
comment: 'Please seach before asking',
childrenLength: 0,
children: []
}, {
id: 9,
comment: 'Please read the documentation',
childrenLength: 0,
children: []
}, {
id: 10,
comment: 'You can see the blog posts on this',
childrenLength: 0,
children: []
}]
}]
var vm = function(){
var self = this
self.comments = ko.observableArray(comments)
}
$('document').ready(function () {
ko.applyBindings(new vm())
})
You can see here is multilevel branching. Now you can achieve this with recursion.
<div class="body" data-bind="foreach: comments">
<div data-bind="template: { name: 'childTemplate', data: $data }"></div>
</div>
<script type="text/html" id="childTemplate">
<span data-bind="text:comment"></span>
<!-- ko if: $data.childrenLength > 0 -->
<!-- ko foreach: children -->
<div data-bind="template: { name: 'childTemplate', data: $data }" style="padding-left:35px;"></div>
<!-- /ko -->
<!-- /ko -->
</script>
Fiddle Demo

Related

CSS and Vue: Style other elements if hover on one for Ratings

I wanna keep it simple. I am about to code a 5 star rating logic.
So I have this array of 5 possible ratings:
const ratingsArray = [
{
name: 'rating1',
ratingValue: 20,
isEnabled: ref(false)
},
{
name: 'rating2',
ratingValue: 40,
isEnabled: ref(false)
},
{
name: 'rating3',
ratingValue: 60,
isEnabled: ref(false)
},
{
name: 'rating4',
ratingValue: 80,
isEnabled: ref(false)
},
{
name: 'rating5',
ratingValue: 100,
isEnabled: ref(false)
},
]
And I have this template. It maps through the array and gives me a circle for every entry:
The class 'ratingBoxChecked' is the class which fills the dot with a color.
<template>
<span>
<div
v-for="(rating, index) in ratingsArray"
:key="rating.name"
#click="updateRating(index, rating.ratingValue)"
:class="[rating.isEnabled.value ? 'ratingBoxChecked' : 'ratingBox']">
</div>
</span>
</template>
How can I hover on one dot and the other ones before that to are hovered and have the class 'ratingBoxChecked', too?
For example, I want to hover on the 3rd dot and the first 2 must
be enabled too! Like a standard rating hover.
Thank you Guys so much!
Ignoring the "click" case for this example (but can be easily stitched together) - see my StackBlitz for a running version.
Code
<script setup>
import { ref } from 'vue';
const ratings = [
{
name: 'rating1',
value: 20,
},
{
name: 'rating2',
value: 40,
},
{
name: 'rating3',
value: 60,
},
];
// When hovering, this ref will be changed to the index of the rating you hover over
const hoveredRating = ref(-1);
// Function to check if styles/text/... should be changed
const shouldRatingShow = (index) => hoveredRating.value >= index;
// Note: This is a naive implementation. You can also check it based on names (e.g. find the index of a rating based on the name and take all before) and so on and so on
</script>
<template>
<span>
<!-- div containing the mouseenter and mouseleave event to change the ref. PS: If you want to make it clickable, this should be a button!! -->
<div
v-for="(rating, index) in ratings"
:key="rating.name"
#mouseenter="hoveredRating = index"
#mouseleave="hoveredRating = -1"
>
{{ rating.name }}
{{ shouldRatingShow(index) ? 'on' : 'off' }}
</div>
</span>
<!-- Debug output -->
{{ hoveredRating }}
</template>

Render nested items based on an API response using materialsUI

im trying to make a nested side menu using nexJS and materialsUI dinamically based on an API response that would look like this:
const Response1 = [
{
id: 1,
name: "Logistics",
icon: "warehouse",
url: "/",
children: [
{
id: 2,
name: "Express",
icon: "precision_manufacturing",
url: "/",
children: [
{
id: 3,
name: "request",
icon: "list_alt",
url: "/Logistica/Express-Cedis",
children: [],
},
],
},
{
id: 5,
name: "Dashboards",
icon: "bar_chart",
url: "/Logistica/Dashboard",
children: [],
},
],
}
]
I was able to iterate the object and get all the items and display them, the only problem is that the ones that are childs should be visible only when clicking the parent, and i only have them all in a list statically, i did this with a code like this:
const mapStructure = (nodes: any) => {
if (nodes) {
return nodes.map((node) => (
<>
<ListItemButton onClick={handleClick}>
<ListItemIcon>
<Icon>{node.icon}</Icon>
</ListItemIcon>
<ListItemText primary={node.name} />
{open ? <ExpandLess /> : <ExpandMore />}
</ListItemButton>
{mapStructure(node.children)}
</>
));
}
};
the idea is that the parent objects display just as the code above, but the children elements display in a collapse like the one below:
<Collapse in={open} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
<ListItemButton sx={{ pl: 4 }}>
<ListItemIcon>
<Icon>{node.icon}</Icon>
</ListItemIcon>
<ListItemText primary={node.name} />
</ListItemButton>
</List>
</Collapse>
i tried something like "if node has a child, render like the first example, and when it doesn´t have childs render like the second examle" but i can´t manage to write it correctly

How do I get values instead of keys from object for use with vue.js binding (:class)

I'm very new to Vue syntax, so please forgive me (and feel free to correct!) my terminology and assumptions. In short, I have a very simple goal, to get values from an object where currently I am getting key names.
In the code I am trying to modify, there is a Vue object called "tags," part of a complete "video" object (returned from Vimeo), that, when bound in a Vue "x-template" script to html - like so:
<figure class="vimeography-thumbnail" :class="video.tags" >
...produces output like this:
<figure data-v-de73d604 data-v-5a40afb8 class="vimeography-thumbnail name canonical name canonical name canonical" index="18">
The output we need instead would look more like this:
<figure data-v-de73d604 data-v-5a40afb8 class="vimeography-thumbnail hands feet eyes" index="18">
In other words, "hands," "feet," and "eyes" would be the values of "canonical" for the set of three "tags." The "data" and "index" elements being output are, I believe, irrelevant.
I got as far as I did through some investigatory hacking around, and, though the result is wrong, I can see from page source that "name" and "canonical" are the correct key names, that the values I need are also present, and that the number of pairs of keys for each video thumbnail is as would be expected given each specific Vimeo video's number of tags.
I do see a lot of discussion about iterating over the object (or is it really an array?), but the :class shorthand seems already to be doing that, so I wonder if there isn't a simple shorthand way to get the values instead of keys. I tried video.tags.values and video.tags[canonical]just for the heck of it, but no luck.
Just to provide a larger context, the script is a template customization script for a WordPress plugin - Vimeography - that has already done the job of constructing the needed variables from the Vimeo API.
The larger template - for modifying gallery thumbnails - looks like this:
<script type="text/x-template" id="vimeography-timber-thumbnail">
<figure class="vimeography-thumbnail" :class="video.tags" >
<img class="vimeography-thumbnail-img" :src="thumbnailUrl" :alt="video.name" />
<figcaption>
<h2 class="vimeography-title">{{video.name}}</h2>
<div class="vimeography-description" v-html="video.description"></div><!-- try two -->
<router-link class="vimeography-link" :to="this.query" :title="video.name" exact exact-active-class="vimeography-link-active">View more </router-link>
</figcaption>
</figure>
</script>
A typical tags object looks like this in page source:
"tags":[{"name":"neck massage","canonical":"neckmassage"},{"name":"release","canonical":"release"},{"name":"shoulder pain","canonical":"shoulderpain"}]
So, as you can see if you return to the output example above, I'm getting the first and second key names "name" and "canonical" in sequence, separated by spaces, when what I need is each second key value.
On request - a video object - the "tags" appear around midway in it.
"466907727":{"uri":"\/videos\/466907727","name":"Headache Relief w\/ Ruth","description":"Give yourself some time with this one. If you feel a headache coming on or you can't get rid of one, try out these techniques to release face, jaw, and ear muscles that tense up throughout the day.","link":"https:\/\/vimeo.com\/466907727","duration":"11:43","width":1280,"height":720,"embed":{"buttons":{"like":true,"watchlater":true,"share":true,"embed":false,"hd":false,"fullscreen":true,"scaling":true},"logos":{"vimeo":false,"custom":{"active":true,"url":"https:\/\/i.vimeocdn.com\/player\/415649.png?mw=100&mh=100","link":"https:\/\/bodyworksdw.com","sticky":true}},"title":{"name":"show","owner":"show","portrait":"hide"},"playbar":true,"volume":true,"speed":false,"color":"ffffff","uri":"\/presets\/120692845","html":"<iframe src=\"https:\/\/player.vimeo.com\/video\/466907727?title=0&byline=0&portrait=0&speed=0&badge=0&autopause=0&player_id=0&app_id=27459\" width=\"1280\" height=\"720\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"Headache Relief w\/ Ruth\"><\/iframe>","badges":{"hdr":false,"live":{"streaming":false,"archived":false},"staff_pick":{"normal":false,"best_of_the_month":false,"best_of_the_year":false,"premiere":false},"vod":false,"weekend_challenge":false}},"created_time":"2020-10-10T17:17:42+00:00","privacy":{"view":"disable"},"pictures":{"uri":"\/videos\/466907727\/pictures\/972886256","active":true,"type":"custom","sizes":[{"width":100,"height":75,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_100x75?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_100x75&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":200,"height":150,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_200x150?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_200x150&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":295,"height":166,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_295x166?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_295x166&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":640,"height":360,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_640x360?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_640x360&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":1280,"height":720,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_1280x720?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":1280,"height":720,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_1280x720?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":1280,"height":720,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_1280x720?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":1280,"height":720,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_1280x720?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},{"width":1920,"height":1080,"link":"https:\/\/i.vimeocdn.com\/video\/972886256_1920x1080?r=pad","link_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1920x1080&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"}],"resource_key":"0e08692aa74f2e89587bd88aedf898a1faa1ccb9","default_picture":false},"tags":[{"name":"Jaw","canonical":"jaw"},{"name":"Head","canonical":"head"},{"name":"Recover","canonical":"recover"}],"stats":{"plays":3},"metadata":{"connections":{"texttracks":{"uri":"\/videos\/466907727\/texttracks","options":["GET","POST"],"total":0}}},"user":{"account":"business"},"download":[{"quality":"sd","type":"video\/mp4","width":426,"height":240,"expires":"2021-05-16T10:05:23+00:00","link":"https:\/\/player.vimeo.com\/play\/2073102730?s=466907727_1621159523_101bba513873dd67b93c563f09e28890&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth139.mp4","created_time":"2020-10-10T17:19:59+00:00","fps":29.97,"size":32299937,"md5":"fcad390159d07049c597c47dd7edc921","public_name":"SD 240p","size_short":"30.8MB"},{"quality":"sd","type":"video\/mp4","width":960,"height":540,"expires":"2021-05-16T10:05:23+00:00","link":"https:\/\/player.vimeo.com\/play\/2073102727?s=466907727_1621159523_03598ebe80a895414613bd3cef32af54&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth165.mp4","created_time":"2020-10-10T17:19:59+00:00","fps":29.97,"size":143540809,"md5":"553cd5d74d4ab59cc16547b486c82a30","public_name":"SD 540p","size_short":"136.89MB"},{"quality":"sd","type":"video\/mp4","width":640,"height":360,"expires":"2021-05-16T10:05:23+00:00","link":"https:\/\/player.vimeo.com\/play\/2073102718?s=466907727_1621159523_613694ef950f06a2a4a06376d9c03708&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth164.mp4","created_time":"2020-10-10T17:19:59+00:00","fps":29.97,"size":56848778,"md5":"282afb947f67e072bfb44b84557ff231","public_name":"SD 360p","size_short":"54.22MB"},{"quality":"hd","type":"video\/mp4","width":1280,"height":720,"expires":"2021-05-16T10:05:23+00:00","link":"https:\/\/player.vimeo.com\/play\/2073102708?s=466907727_1621159523_0d0c2d785bc32949b4eca945a220741a&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth174.mp4","created_time":"2020-10-10T17:19:59+00:00","fps":29.97,"size":244431967,"md5":"8db87793d97332351b77aba3d1e5a042","public_name":"HD 720p","size_short":"233.11MB"}],"status":"available","video_id":"466907727","id":466907727,"human_created_time":"October 10, 2020","thumbnail_tiny":"https:\/\/i.vimeocdn.com\/video\/972886256_295x166?r=pad","thumbnail_tiny_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_295x166&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","thumbnail_small":"https:\/\/i.vimeocdn.com\/video\/972886256_640x360?r=pad","thumbnail_small_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_640x360&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","thumbnail_medium":"https:\/\/i.vimeocdn.com\/video\/972886256_1280x720?r=pad","thumbnail_medium_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","thumbnail_large":"https:\/\/i.vimeocdn.com\/video\/972886256_1280x720?r=pad","thumbnail_large_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"},
A simple inlined method within your script template tag should suffice:
:class="
video.tags.reduce((classes, obj) => {
classes.push(obj.canonical)
return classes
}, [])
"
This should be sufficient enough to reduce down the existing array of objects into a simple array of string values.
As for why this happens - in the object syntax for classes, vue looks at the left hand assignment and will apply it if the right hand assignment is truthy. in your case, the indices are applied because the values of them are strings, which are truthy.
couldn't get your problem exactly, if you want to print the value call it by its property name ".name" as you did, but you have to be sure that video is a single object.
<figure
v-for="(item, index) in tags"
:v-key="index"
data-v-de73d604
data-v-5a40afb8
:class="item.name + item.canonical"
class="vimeography-thumbnail"
:index="18 + index"
></figure>
with tags array
<template>
<div id="app">
<!-- ..-->
<figure
v-for="(item, index) in tags"
:v-key="index"
data-v-de73d604
data-v-5a40afb8
:class="item.name + ' ' + item.canonical"
class="vimeography-thumbnail"
:index="18 + index"
></figure>
<!-- ..-->
</div>
</template>
<script>
import HelloWorld from "./components/HelloWorld";
export default {
data() {
return {
tags: [
{ name: "neck massage", canonical: "neckmassage" },
{ name: "release", canonical: "release" },
{ name: "shoulder pain", canonical: "shoulderpain" },
],
};
},
};
</script>
//new Update
<template>
<div id="app">
{{ video.tags }}
<figure
v-for="(item, index) in video.tags"
:v-key="index"
data-v-de73d604
data-v-5a40afb8
:class="item.name + ' ' + item.canonical"
class="vimeography-thumbnail"
:index="18 + index"
></figure>
</div>
</template>
<script>
export default {
mounted(){
var get = {
466907727: {
uri: "/videos/466907727",
name: "Headache Relief w/ Ruth",
description:
"Give yourself some time with this one. If you feel a headache coming on or you can't get rid of one, try out these techniques to release face, jaw, and ear muscles that tense up throughout the day.",
link: "https://vimeo.com/466907727",
duration: "11:43",
width: 1280,
height: 720,
embed: {
buttons: {
like: true,
watchlater: true,
share: true,
embed: false,
hd: false,
fullscreen: true,
scaling: true,
},
logos: {
vimeo: false,
custom: {
active: true,
url: "https://i.vimeocdn.com/player/415649.png?mw=100&mh=100",
link: "https://bodyworksdw.com",
sticky: true,
},
},
title: { name: "show", owner: "show", portrait: "hide" },
playbar: true,
volume: true,
speed: false,
color: "ffffff",
uri: "/presets/120692845",
html:
'<iframe src="https://player.vimeo.com/video/466907727?title=0&byline=0&portrait=0&speed=0&badge=0&autopause=0&player_id=0&app_id=27459" width="1280" height="720" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen title="Headache Relief w/ Ruth"></iframe>',
badges: {
hdr: false,
live: { streaming: false, archived: false },
staff_pick: {
normal: false,
best_of_the_month: false,
best_of_the_year: false,
premiere: false,
},
vod: false,
weekend_challenge: false,
},
},
created_time: "2020-10-10T17:17:42+00:00",
privacy: { view: "disable" },
pictures: {
uri: "/videos/466907727/pictures/972886256",
active: true,
type: "custom",
sizes: [
{
width: 100,
height: 75,
link: "https://i.vimeocdn.com/video/972886256_100x75?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_100x75&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 200,
height: 150,
link: "https://i.vimeocdn.com/video/972886256_200x150?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_200x150&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 295,
height: 166,
link: "https://i.vimeocdn.com/video/972886256_295x166?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_295x166&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 640,
height: 360,
link: "https://i.vimeocdn.com/video/972886256_640x360?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_640x360&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 1280,
height: 720,
link: "https://i.vimeocdn.com/video/972886256_1280x720?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 1280,
height: 720,
link: "https://i.vimeocdn.com/video/972886256_1280x720?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 1280,
height: 720,
link: "https://i.vimeocdn.com/video/972886256_1280x720?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 1280,
height: 720,
link: "https://i.vimeocdn.com/video/972886256_1280x720?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
{
width: 1920,
height: 1080,
link: "https://i.vimeocdn.com/video/972886256_1920x1080?r=pad",
link_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1920x1080&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
],
resource_key: "0e08692aa74f2e89587bd88aedf898a1faa1ccb9",
default_picture: false,
},
tags: [
{ name: "Jaw", canonical: "jaw" },
{ name: "Head", canonical: "head" },
{ name: "Recover", canonical: "recover" },
],
stats: { plays: 3 },
metadata: {
connections: {
texttracks: {
uri: "/videos/466907727/texttracks",
options: ["GET", "POST"],
total: 0,
},
},
},
user: { account: "business" },
download: [
{
quality: "sd",
type: "video/mp4",
width: 426,
height: 240,
expires: "2021-05-16T10:05:23+00:00",
link:
"https://player.vimeo.com/play/2073102730?s=466907727_1621159523_101bba513873dd67b93c563f09e28890&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth139.mp4",
created_time: "2020-10-10T17:19:59+00:00",
fps: 29.97,
size: 32299937,
md5: "fcad390159d07049c597c47dd7edc921",
public_name: "SD 240p",
size_short: "30.8MB",
},
{
quality: "sd",
type: "video/mp4",
width: 960,
height: 540,
expires: "2021-05-16T10:05:23+00:00",
link:
"https://player.vimeo.com/play/2073102727?s=466907727_1621159523_03598ebe80a895414613bd3cef32af54&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth165.mp4",
created_time: "2020-10-10T17:19:59+00:00",
fps: 29.97,
size: 143540809,
md5: "553cd5d74d4ab59cc16547b486c82a30",
public_name: "SD 540p",
size_short: "136.89MB",
},
{
quality: "sd",
type: "video/mp4",
width: 640,
height: 360,
expires: "2021-05-16T10:05:23+00:00",
link:
"https://player.vimeo.com/play/2073102718?s=466907727_1621159523_613694ef950f06a2a4a06376d9c03708&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth164.mp4",
created_time: "2020-10-10T17:19:59+00:00",
fps: 29.97,
size: 56848778,
md5: "282afb947f67e072bfb44b84557ff231",
public_name: "SD 360p",
size_short: "54.22MB",
},
{
quality: "hd",
type: "video/mp4",
width: 1280,
height: 720,
expires: "2021-05-16T10:05:23+00:00",
link:
"https://player.vimeo.com/play/2073102708?s=466907727_1621159523_0d0c2d785bc32949b4eca945a220741a&loc=external&context=Vimeo%5CController%5CApi%5CResources%5CUser%5CAlbum%5CVideosController.&download=1&filename=Headache%2BRelief%2Bw%252F%2BRuth174.mp4",
created_time: "2020-10-10T17:19:59+00:00",
fps: 29.97,
size: 244431967,
md5: "8db87793d97332351b77aba3d1e5a042",
public_name: "HD 720p",
size_short: "233.11MB",
},
],
status: "available",
video_id: "466907727",
id: 466907727,
human_created_time: "October 10, 2020",
thumbnail_tiny: "https://i.vimeocdn.com/video/972886256_295x166?r=pad",
thumbnail_tiny_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_295x166&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
thumbnail_small: "https://i.vimeocdn.com/video/972886256_640x360?r=pad",
thumbnail_small_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_640x360&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
thumbnail_medium:
"https://i.vimeocdn.com/video/972886256_1280x720?r=pad",
thumbnail_medium_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
thumbnail_large:
"https://i.vimeocdn.com/video/972886256_1280x720?r=pad",
thumbnail_large_with_play_button:
"https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F972886256_1280x720&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png",
},
};
// here we check if the getting data is array or object and make it okay to video object.
get == Array.isArray()
? (this.video = get[0])
: (this.video = get[Object.keys(get)]);
},
data(){
return{
video:{
}
}
}
}
</script>

react-jsonschema-form collapses the size of my array form and cuts off buttons

I've started building a form in react-jsonschema-form and i'm having a lot of difficulty changing it visually.
The form is an array and it has a button to add and remove a set of input boxes.
I've build it as a component in a test project which has no css applied to it so far.
The form will render as a tiny box where there is no room for the buttons (they are cut of as shown below in images).
a single element
a second element
How its supposed to look on react-jsonschema-form playground
A key difference between my array and the sample array is that i'm having two text input elements per array element. I dont know if this could cause it.
I do need to have two input values as its a group of data that is related, and both is required.
This is my code:
//json schema
const schema = {
type: "object",
properties: {
listOfNumbers: {
title: "opret ledig nummerserie",
type: "array",
required: ["nr_fra", "nr_til"],
items: {
properties: {
nr_fra: {
type: "string",
pattern: "^\\d*$",
minLength: 8,
maxLength: 8,
},
nr_til: {
type: "string",
pattern: "^\\d*$",
minLength: 8,
maxLength: 8,
},
},
},
},
},
};
//uiSchema
const uiSchema = {
listOfNumbers: {
"ui:options": {
orderable: false,
},
items: {
//nr_fra: { "ui:options": { label: false } },
//nr_til: { "ui:options": { label: false } },
},
},
}
I'm applying no css to the below form.
// Form
<Form
schema={schema}
uiSchema={uiSchema}
formData={this.state.formData}
onSubmit={(formOutput) => this.handleSubmit(formOutput)}
transformErrors={transformErrors}
/>
I've spent a day and a half on trying to strongarm this, but i could really use some help on how to proceed.
It seems it was css inputs that was needed to solve this.
The below will expand the elements to their proper size/form.
Posting this here for posterity, as this is not accurately documented.
<div className="col-md-offset-3 col-md-6">
<Form schema={schema}
uiSchema={uiSchema}>
</Form>
</div>

Want to make cell of 1 row of angular ui grid columndef editable

how to change columndef settings dynamically loaded , like one row must be editable and other should not be editable when loaded,but mine whenever celleditable true for one row it makes all other rows cells also editable
I can't understand if you meant 1 row or row 1. But customizing the celltemplates of columns based on rowRenderIndex might help.
var gridOptions = {
enableFiltering: true,
rowTemplate: rowTemplate(),
data: [{one : 1, two : 2, three: 3, four : 4, five:5 }],
columnDefs: [
{ field: 'one' },
{ field: 'two' },
{ field: 'three' },
{ field: 'four' },
{ field: 'five', cellTemplate: '<div class="ui-grid-cell-contents">
<input ng-if="!rowRenderIndex" type=number />
<span ng-if="rowRenderIndex">{{row.entity.five}}</span>
</div>'}
]
};

Resources