Two different rows of label styles in React-Select - react-select

I want to have a bold title in one row and second row normal style for Select options. I tried to use formatOptionalLabel but now displaying the second row.
For example here is my options,
const options = [ {label: "once", seconsLabel: "One time only", value: "0"}, {label: "Weekly", seconsLabel: "Once a week", value: "1"}];

Related

How to change the value of a sanity field

So i want to change the value of a specific field called "likes"
Here is the schema:
//...
fields: [
{
name: "likes",
title: "Likes",
type: "number",
}
]
I want to change the like count when a button is pressed. it should change the like count by +1.
How to change the value?
You can use client.patch(doc).inc({likes: 1}).commit() to increment your likes field each time it's called.

How to change Language of PrimeVue Datatable Buttons and Filters

How can I change the language of Primefaces PrimeVue Datatable Buttons and filters?
These are standard fields of primeVue datatable:
Filter:
/**
* Filter option translation
*/
const matchModesOptions = [
{label: 'Gleich...', value: FilterMatchMode.EQUALS},
{label: 'Nicht gleich...', value: FilterMatchMode.NOT_EQUALS},
{label: 'Beginnt mit...', value: FilterMatchMode.STARTS_WITH},
{label: 'Endet mit...', value: FilterMatchMode.ENDS_WITH},
{label: 'Beinhaltet...', value: FilterMatchMode.CONTAINS}
]
There is an mistake at the documentation of primevue. This is how it works.

Populate data with custom function

How can I add custom filter options AND all the other data to a custom function?
Below is my code. I would like to have Yes and No filters, but also filters for all the other values in the column.
{column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},
You should use the append_data_to_table_data option for your filter
From docs:
append_data_to_table_data
Required: false
Type: string
Default value: undefined
Possible values: before / sorted
Description: Use 'before' to place your data array before the values that yadcf grabs from the table
use 'sorted' to place the data array sorted along with the values that yadcf grabs from the table
Note: 'sorted' option will have affect only if you data is an array of primitives (not objects)
So eventually your code will look like this
{
append_data_to_table_data: 'before',
column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},

How do you set <select> value/option in edit/new template - ExpressJS

I'm trying to use a partial to share a _form.html across an new.html and edit.html templates in ExpressJS. The problem is with the select tag.
How do you get a select HTML element to have the correct option selected in an edit form? If you use
<select value="#{blob.kind || ''}">
The select doesn't show the option whose value is equal to the blob.kind.
In order to specify a selected option, a selected attribute needs to be added to the option element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
Assuming the blob.kind property is a value string, you could write the Jade for your select and option elements as follows:
-
var options = [
{value: 'option1', text: 'Option 1'},
{value: 'option2', text: 'Option 2'},
{value: 'option3', text: 'Option 3'},
{value: 'option4', text: 'Option 4'}
];
select
each obj in options
if (blob.kind === obj.value)
option(value= obj.value, selected)= obj.text
else
option(value= obj.value)= obj.text
For future reference, Jade has been renamed to Pug.
I used to do this as follows:
select
each obj in options
option(value= obj.value, selected=blob.kind === obj.value ? true : false)=
obj.text
Sean's suggestion is excellent, but his syntax didn't quite work for me. Here's what I ended up with:
- const stateOptions = [{value:'AL', text:'Alabama'}, ...]
select#state(name='state' required)
each option in stateOptions
if (option.value === meeting.state)
option(value=(option.value) selected) #{option.text}
else
option(value=(option.value)) #{option.text}

dojo FilteringSelect avoid Accented characters

I'm using a FilteringSelect that use an FilteringSelect as store.
I want to ignore the accented characters that users can enter, and to return all the elements with or without accents. But i don't know what event i have to catch.
Here's my code :
var ccppMemory = new dojo.store.FilteringSelect({
data: centrosPoblado,
idProperty: "id"
});
sboMunicipio = new dijit.form.FilteringSelect({
id: "soMunicipioSelect",
hasDownArrow: false,
placeholder: i18n.tools.searches.ordinary.departmentTown,
store: ccppMemory,
searchAttr: "unitario",
intermediateChanges : true,
queryExpr: "*${0}*",
autoComplete: false,
highlightMatch: "all",
style:"margin-right:5px;width:170px;"
}, "soMunicipioSelect");
sboMunicipio.startup();
To explain better, centrosPoblado is an array that i populate as :
centrosPoblado.push({
id: value.attributes.CODIGO_DANE,
label: value.attributes.NOMBRE_CENTRO_POBLADO,
unitario: value.attributes.DEPTO + " / " + value.attributes.NOMBRE_CENTRO_POBLADO
});
In 'unitario' i have store strings like 'Medellín', ' Bogotá', ....
What i want is that when a user enter medellín, the filterselect ignore and returns 'Medellín' . So what i think i have to do it's to substitute medellin for something like m[eé]d[eé]ll[íi]n, but i don't know where.
Thanks
if anyone is interested, here is the answer :
http://dojo-toolkit.33424.n3.nabble.com/FilteringSelect-avoid-Accented-characters-td4004099.html
You have to overwrite the 'queryEngine' of the Memory that its linked to the FilteringSelect