Comments (6)
there is no builtin type like that
but you could do it
{
"schema": {
"colors":{
"type": "object",
"title": "properties colors",
"properties": {
"all":{
"type":"checkbox"
},
"selections":{
"type":"array",
"title": "list",
"items": {
"type": "string",
"enum": [
"INFO",
"LOG",
"WARN",
"ERROR",
"DEBUG"
]
}
}
}
}
},
"form":[
{
"title": "Settings",
"type": "fieldset",
"expandable": false,
"order": 0,
"items": [
{
"key":"colors.all",
"title":"All",
"onChange": "(evt,node)=>",
"function setc(p,s){p.find('legend').first().css('color',s?'red':'blue')};",
"var selection=$(evt.target).prop('checked');",
"var parent =$(evt.target).closest('fieldset');",
"var allchecked=parent.find(\"input[name$='disabled']:checked\").length;",
"var count=parent.find(\"input[name$='disabled']\").length;",
"if(selection===true && allchecked!==count){selection=false};",
"setc(parent,selection);}"
},
{
"key": "colors.selections",
"type": "checkboxes",
"notitle":true
}
]
}
]
}
but you will have to code up the onChange handler to flip them all on or off
I posted one of mine for example.. look thru the content and then use jquery operations to find the checkboxes and
check or uncheck them
from playground
without the onChange coded (I wrapped that over multiple lines for visbility here, which isn't supported in json)
from jsonform.
and you could code an onChange for the checkboxes to change the text color as well
and u might be able to use a section type for the All checkbox to keep it out of the object itself
from jsonform.
Thanks for the response and this could work for me as an alternative. But could the same thing be done in a dropdown scrollable list(since i will have a 100 options to choose from). The current structure is directly displayed and when 100 options are available in the page it will either become crowded or the entire page will run long. A scrollable dropdown list which would have a 100 options (this can be done), a list of checkboxes (also can be done like you have shown). But can this both be combined to have scrollable dropdown list with a checkbox option next to each of the options?
from jsonform.
I don't think there is any way to accomplish this with the existing capabilities. BUT one could create a new type, and use the jQuery select2 type to implement the list. (as jsonform depends on jQuery)
I created a key:value pair type for one of my projects.
is there a reason u want checkbox AND text, if it's multi select and the text is highlighted?
from jsonform.
I added support in the base.. , would u like to try it out on my fork .
whereever your jsonform folder is, rename it out of the way,
git clone https://github.com/sdetweil/jsonform
to recreate the folder in the same place
then in the created jsonform folder do
git checkout scrollable_checkboxes
in the form u can add
scrollable:true,
height: x
where x is number of em's high to make the scroll box
example (this file one folder beside node modules, change the paths
then use browser file:///path to this html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>listtest form select </title>
<link rel="stylesheet" style="text/css" href="../node_modules/jsonform/deps/opt/bootstrap.css" />
</head>
<body style="margin:30px;">
<h1>heading</h1>
<form></form>
<div id="res" class="alert"></div>
<script type="text/javascript" src="../node_modules/jsonform/deps/jquery.min.js"></script>
<script type="text/javascript" src="../node_modules/jsonform/deps/underscore.js"></script>
<script type="text/javascript" src="../node_modules/jsonform/lib/jsonform.js"></script>
<script type="text/javascript" src="../node_modules/jsonform/deps/opt/jsv.js"></script>
<script type="text/javascript" src="../node_modules/jsonform/deps/opt/jquery-ui.js"></script>
<script type="text/javascript" src="../node_modules/jsonform/deps/opt/ace/ace.js"></script>
<script type="text/javascript">
$('form').jsonForm(
{
schema: {
name: {
type: 'object',
properties:{
list:{
"type": "array",
"title": "Options",
"items": {
"type": "string",
// "type": "checkboxes" // is error now, not allowed in schema
"title": "Option",
"enum": [
"one",
"two",
"four",
'ten'
]
}
},
fribble:{
type: 'object',
properties:{
list:{
"type": "array",
"title": "Options",
"items": {
type: "string",
enum: [
"six",
"seven",
"eight",
'nine'
]
}
}
}
},
foobar: {
type:'string',
enum: [
"foo",
"bar"
]
}
}
}
},
form:[
{
"title": "Settings",
"type": "fieldset",
"expandable": false,
"order": 0,
"items": [
{
"key":"name.list",
type: "checkboxes",
scrollable: true,
height:5
},
{
"key": "name.fribble.list",
"type": "checkboxes"
},
{
"title":"test of enum on not array",
key:"name.foobar"
// , "type":"checkboxes" // is error now, schema item not array
}
]
},
{
"type": "submit",
"title": "Save, Create config",
"id": "submit_button"
}
],
value:{
name:{
list: ['one','ten'],
fribble: { list: ['seven'] }
}
},
onSubmit: function (errors, values) {
if (errors) {
$('#res').html('<p>I beg your pardon?</p>');
}
else {
$('#res').html("test results="+ JSON.stringify(values),'</p>');
}
}
}
);
</script>
</body>
</html>
i see this
scrollable,
not scrollable,
not array
from jsonform.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from jsonform.
Related Issues (20)
- Add custom field to fieldset HOT 2
- activeClass isn't applied correctly for schemas with defaults HOT 2
- How to build a stepper form HOT 4
- process change, just fyi.. all PRs against develop branch
- Expanded Fieldset + Default TabIndex set - Collapse issue (bug) HOT 4
- tabs-left not supported in bootstrap v3
- Hide submit button HOT 2
- How to escape slash in scope HOT 3
- Rendering fails if property name contains dots HOT 1
- Missing array brackets [] on array items when using a custom field type HOT 1
- Error: JSONForm does not yet support schemas that use the $ref keyword. See: #54" HOT 2
- Boolean options are always true HOT 5
- How to use this library with bundler HOT 1
- How to show error after a control value is changed, HOT 1
- date / datetime formatting HOT 3
- Advancedfieldset form folding click handle gets duplicated when jsonform gets called again causing the folded form to flick HOT 6
- Textarea Rows HOT 2
- Fieldset along with the Select all checkbox. HOT 7
- Array binding issue HOT 7
- Swapping the images HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonform.