What shape should value prop have? (v1.x) - react-select

v1.x
What should I set as a value prop for Select.Async to have it work properly.
I have options defined as array of {value,label} pairs. Doeas that mean that value prop should also be shaped like that (with multi) prop.
I cannot find anything about that in documentation.
I set value to just array of integers, (and value key in options is as well an integer of course) everything works till moment I reload the page (remount component) and start changing the input. Then everything is gone. Works perfectly with objects.
Is my assumption correct that value has to be also {value,label} object/array of objects?

Your assumption is not correct. The value prop does not have to be of type object.
Here is its type definition from the documentation:
Property | Type | Default | Description
value | any | undefined | initial field value
If you want to use an object, you donĀ“t have to follow the assumption that you need value and label attributes in the objects representing your options. If you set the labelKey and valueKey props to the specific attribute names, you can use any combination of attributes representing value and label.

Related

How to expand this dynamic column with only 1 value

This Id column is dynamic type, but only holds 1 value (f3019...). I want to get rid of the array so it only has the field value.
When I try mv-expand Id it doesn't do anything
Also the current query is like:
Id = Target.Properties[0].value
When I try
Id = Target.Properties[0].value[0]
Id returns a blank
The dynamic types can hold arrays and dictionaries, but also scalar types.
The fact that Target.Properties[0].value does not behave like an array indicates that it is not an array, but a string.
The representation of it as an array in the GUI relates to the serving lair and not the way it is actually stored.
Use tostring(parse_json(tostring(Target.Properties[0].value))[0]).
Every element within a dynamic field is also of dynamic type.
When running on a dynamic element, parse_json() returns the element As Is.
If we want the element to get parsed, we first need to convert it to string, using tostring().
parse_json() which is used to parse the string, returns an array (which is a dynamic element).
The first (and only) element of the array is also of a dynamic type.
We use an additional tostring() to convert it to string.
Demo
print value = dynamic('["Hello"]')
| extend value[0] // Null because it's not really an array
| extend result = tostring(parse_json(tostring(value))[0])
value
value_0
result
["Hello"]
Hello
Fiddle
Misleading representation in Azure Monitor:

How to structure message and update functions with a variable number of UI elements in Elm?

Greetings StackOverflow!
Suppose I have an Elm app with a variable number of text input fields. I'd like to reflect the state of these input fields in the model.
Model and view are easy enough: View just has a Array String field in it somewhere.
The view is then computed simply by calling List.map (HTML input ...) on that list of strings.
However, I'm a bit lost how to do the update function and message type.
The message could be somethign like this:
type Msg = InputFieldUpdated Int String
Here, the Int refers to the position in the Array that the string to be updated has. However, if I do it this way, I can create messages that refer to non-existant array positions simply by setting the Int to something that is out of range.
For a fixed number of input elements, one can solve this problem very elegantly by simply using a union type with a different value for each input, but what about my situation? In the domain of "making impossible states impossible", is there some trick for that that I'm missing?
However, if I do it this way, I can create messages that refer to non-existant array positions simply by setting the Int to something that is out of range.
According to the documentation of Array.set, the array stays untouched if the index is out of range.
Please, have a look at this ellie-app example. It mostly models the problem, that you've described. Array of elements is rendered and the elements can be added dynamically:
view : Model -> Html Msg
view model =
div []
[ div [] (toList (Array.indexedMap viewElement model.elements))
, button [ onClick Add ] [ text "Add" ]
]
In order to update a particular element, you need to get it by index. Since the type of the result from Array.get is Maybe a, type system will force you to process all the cases (when the element exists and doesn't):
Increment index ->
case get index model.elements of
Just element ->
{ model | elements = set index (element + 1) model.elements }
Nothing ->
model
The example is just for demonstration purposes, if you don't need the current element, then Array.set function can be safely used.

Ocean SDK get property value at cell

In my plugin I get property as an input parameter. I'm trying to get property value at particular cell. I've checked that value at the cell is really defined, but I get Nan.
Code sample:
double permValueCell;
Index3 TestIndex = new Index3(54,8,7);
permValueCell = _propPermeability[TestIndex];
Firstly I thought that there is some problem in getting property as parameter, but during debug I saw that description section of the property displays a correct name. What can be wrong ?
In Petrel, the cell index seen in the UI is not the same as stored in Ocean.
You can convert between the two by using the ModelingUnitSystem class in Petrel 2014.
Look at :
Slb.Ocean.Petrel.ModelingUnitSystem.ConvertIndexFromUI
Slb.Ocean.Petrel.ModelingUnitSystem.ConvertIndexToUI

Bind NSSlider with NSTableView

Data:
An entity with an attribute 'page' (int).
Interface:
NSSlider- value is bound to NotesController.selection.page
NSTableView- value of column 1 is bound to NotesController.arrangedObjects.page
I want to be able to interact with either component and have the change be reflected in both. Above setup works perfectly when I switch between rows in tableview (the slider goes to the corresponding value). However when I play around with slider it changes the value of the selected row instead of changing the index of selected row. This is obviously easily fixable with target/action but is there any workaround that only uses bindings? Thanks.
You need to bind your slider's value to NotesController.selectionIndex.

How to use a single NSValueTransformer subclass to toggle the titles of multiple menu items

I would like to make some bindings that toggle item titles in a popup menu based on a single numerical value in a text field. Let me explain:
This is my UI:
I want my menu items to automatically adjust to singular or plural based on the number in the text field. For example, when I type "1" in the box, I want the menu items to be labeled "minute", "hour" and "day". When I type "4", I want the menu items to be labeled "minutes", "hours" and "days".
What I did to date:
I bound the three menu item's labels to the same key path as the text field's value.
I created an NSValueTransformer subclass to interpret the value in the text field and return singular or plural to be used as item titles.
I applied this value transformer to the three bindings.
The issue:
My value transformer can either return singular or plural but it can't set the appropriate string based on the menu item it's applied to.
It looks to me like a value transformer is generic and can't return different values for different destinations. That would mean that to have the three titles change automatically, I would need to have three different value transformers that return the appropriate string for each menu item. That doesn't seem optimal at all.
Ideally I would be able to combine a string stored in the destination menu item (let's say in the item's tag property) with an "s" in the value transformer when the text field's value is larger than one, or something similar that would enable me to use a single value transformer for all the menu items.
Is there something I missed? What would be an ideal solution?
Okay, this is probably not an ideal solution, but something you could consider: if you set your value transformers from your code (and not in IB), you could instantiate 3 different transformers of the same class. You could give your value transformer an ivar NSString *unit (and add something like [[MyValueTransformer alloc] initWithUnit:]) to allow each to return their own string, but you still have to write the value transformer's code only once.
(Also, if you're ever going to consider making your application localizable, simply appending an "s" to create the plurals is not going to work. You could of course add ivars for both NSString *singular and NSString *plural to do that.)
Edit: Wait, I just realized you can register value transformers! If you register them as MyValueTransformerHours and MyValueTransformerMinutes (by manually allocating and initializing them in your code), you can use them from Interface Builder. See also https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ValueTransformers/Concepts/Registration.html#//apple_ref/doc/uid/20002166-BAJEAIEE.