How to Specify Checkbox List Values in JTable Jquery Plugin - jquery-jtable

I am using JTable Jquery plugin, and one of the columns is a checkbox. When creating/editing, this column should show a list of checkboxes of names of locations, which the user can un/check. I've set the type to checkbox as shown below. What else do I need to do to make the checklist show?
location: {
title: 'Location(s)',
width: '50%',
type: 'checkbox',
options: 'http://localhost/proj/locations'
},
The options property returns a list of all the locations. Or how does one specify the list of values to be used? If type was radiobutton, this works alright. When it is checkbox, doesn't work. What else do I need to provide? The docs say one can provide 3 additional options, but these are optional too.

If you want to use checkbox then location field should be Boolean field. Check this link.
Following is example for checkbox:
location: {
title: 'Location(s)',
width: '50%',
type: 'checkbox',
values: { 'false': 'False', 'true': 'True' },
defaultValue: 'true'
},
And you can not use options property with checkbox type. You can only use options property with radiobutton type or dropdown.

Related

Tabulator Multiselect - How to set a list of default values and display them in the header filter?

I have a multiselect header filter in my Tabulator table initialized as so:
{
title: "Building",
field: "Building",
headerFilter: true,
editor: "select",
headerFilterParams: {
values: buildings,
multiselect:true, //allow multiple entries to be selected
}
}
After the table initialization, I tried to set the filters for the building column as such
table.setFilter("Building", "in", userBuildings);
table.refreshFilter();
The filters are successfully submitted back to the server for filtering, but are not displayed in the table header. I can't find any reference to set the defaultValue field to an array and was wondering if anyone knows of a way to achieve that.
Thanks in advance!

searching a word does not work in combobox in ext 7 version

i have a combobox in EXT version 7 code. I have the editable config as true. My code is as below. This code is similar to what is present in the sencha docs. I have just changed the editable config to true . When we type anything in textfield it appends random characters and the search does not work as expected. Is it a bug with Ext 7? I am not able to figure out. Is someone else also facing something similar?
Ext.create({
fullscreen: true,
xtype: 'container',
padding: 50,
layout: 'vbox',
items: [{
xtype: 'combobox',
label: 'Choose State',
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
// For the dropdown list
itemTpl: '<span role="option" class="x-boundlist-item">{abbr} - {name}</span>',
// For the content of the text field
displayTpl: '{abbr} - {name}',
editable: true,
store: [
{ abbr: 'AL', name: 'Alabama' },
{ abbr: 'AK', name: 'Alaska' },
{ abbr: 'AZ', name: 'Arizona' }
]
}]
});```
I have the same problem with the combobox component in the modern toolkit. I tried the same setup in the Ext JS Version 6.5 and the same error occured.
The only workaround I found for now was to not use the displayTpl config.
Then it worked as intended.
EDIT:
I debugged a little bit into the ext-modern-all and found a solution.
If you want to be able to edit the input field as well as to use the displayTpl you have to set forceSelection: true. Otherwise it will treat your entry as new record and this bug will occur. (https://docs.sencha.com/extjs/7.0.0/modern/Ext.field.ComboBox.html)
I hope this helps.
IDK why the first answer was chosen as the correct answer, I hope my answer below can enlarge your knowledge minimally. When your problem was:
"When we type anything in textfield it appends random characters and the search does not work as expected."
I wanna try to understand that statement like this:
"You want to try to search the item on your store or options by typing random character at any position of any matched item"
At this case, you must add these properties to your combobox to achieve the goal:
anyMatch : true, // this is the key
caseSensitive : false, //by default this has been set automatically
minChars: 0,//by default this has been set automatically too
forceSelection: false // set to false to allow free input to textfield with no matched result and set to true to force the user to choose one of the last matched result rather than giving the opportunity to input free text
Before we conclude that the problem is a bug or not, we need to do the whole researches to get the exact conclusion. Don't forget to learn more on
https://docs.sencha.com/extjs/7.0.0/modern/Ext.field.ComboBox.html
Hope this help you.

Using array destructuring as the value for multiple-choice questions with Inquirer?

I have a dilemma, my code is:
inquirer.prompt([
{
type: 'checkbox',
name: 'Keywords',
message: 'Please select the keywords you would like to use with a maximum of 5.',
choices: [
NewDescriptionKeys[0],
NewDescriptionKeys[1],
NewDescriptionKeys[2],
NewDescriptionKeys[3],
NewDescriptionKeys[4],
]
}
]).then(function (answers) {}//other non-related code is here
My problem is, I can sometimes have more then 5 results, and need to display all of them, so the user can select the ones they want to use, and deselect the ones they don't, I've tried just putting each array until I reach the possible maximum that could be returned, but that just puts undefined's everywhere, any suggestions?
Simplify it with
{
type: 'checkbox',
name: 'Keywords',
message: 'Please select the keywords you would like to use with a maximum of 5.',
choices: NewDescriptionKeys
}
and
Please use the Spacebar to select not enter(return)
(Press <space> to select, <a> to toggle all, <i> to inverse selection)
If you press the enter without selection(without pressing spacebar) then it submits the unselected result with is the empty array.
Enter work as submit
Why not this:
{
type: 'checkbox',
name: 'Keywords',
message: 'Please select the keywords you would like to use with a maximum of 5.',
choices: NewDescriptionKeys
}

KeystoneJS relationship type, limit available items by field value

Is it possible to limit available displayed options in a relationship type of KeystoneJS by specifying a value condition?
Basically, a model has two sets of array fields, instead of letting the admin user select any item from the field, I would like to restrict to only the items that are part of a specific collection _id.
Not sure if this is exactly the feature you're looking for, but you can specify a filter option on the Relationship field as an object and it will filter results so only those that match are displayed.
Each property in the filter object should either be a value to match in the related schema, or it can be a dynamic value matching the value of another path in the schema (you prefix the path with a :).
For example:
User Schema
User.add({
state: { type: Types.Select, options: 'enabled, disabled' }
});
Post Schema
// Only allow enabled users to be selected as the author
Post.add({
author: { type: Types.Relationship, ref: 'User', filter: { state: 'enabled' } }
});
Or for a dynamic example, imagine you have a role setting for both Posts and Users. You only want to match authors who have the same role as the post.
User Schema
User.add({
userRole: { type: Types.Select, options: 'frontEnd, backEnd' }
});
Post Schema
Post.add({
postRole: { type: Types.Select, options: 'frontEnd, backEnd' },
// only allow users with the same role value as the post to be selected
author: { type: Types.Relationship, ref: 'User', filter: { userRole: ':postRole' } }
});
Note that this isn't actually implemented as back-end validation, it is just implemented in the Admin UI. So it's more of a usability enhancement than a restriction.
To expand on Jed's answer, I think the correct property (at least in the latest version of KeystoneJS 0.2.22) is 'filters' instead of 'filter'. 'filter' doesn't work for me.

How to get the unchecked checkbox values of JQGrid for each row when form submitted

I have a JQGrid with a checkbox column as shown below. Once I enter the required data in JqGrid, I do a form submit. From the http posted file I can read the values entered in each field for textboxes and dropdowns(all of these are required). But for Checkbox user can either check or uncheck. When form is submitted I only get the checked values of checkbox. I am retrieving the values as shown below. How to retrieve the values of unchecked checkboxes as well, when form is submitted
string[] checkValue = context.Request.Form.GetValues("clientView");
{ name: 'clientView', index: 'clientView', width: 100, editable: true, edittype: "checkbox", editoptions: { value: "True:False", defaultValue: false }, align: 'center' },
Fixed it as per the Demo. Added a Hidden field to save the checked and unchecked values of checkbox

Resources