What are rawToValue and valueToRaw in Extjs pickerfield? - picker

I'm using Extjs 6.5. I want to implement a picker that have 4 fields: String, Number, Combobox, Color.
I want to save value as an object as follow:
{
string: 'its my name',
number: 12,
combobox: 'combo',
color: 'ffffffff'
}
That means when you call field.getValue() it return above object, but In field textfield only string value is shown. User can expand picker and edit some fields. I can't understand whats rawToValue and valueToRaw in Ext.form.field.picker? What are these?

Basically picker is extend from field and this field have both methods valueToRaw & rawToValue
Hierarchy of extend of picker you can see here ExtJs pickerfield
rawTovalue converts a raw input field value into a mixed-type value that is suitable for this particular field type. This allows controlling the normalization and conversion of user-entered values into field-type-appropriate values, e.g. a Date object for Ext.form.field.Date, and is invoked by getValue.
It is up to individual implementations to decide how to handle raw values that cannot be successfully converted to the desired object type.
valueToRaw converts a mixed-type value to a raw representation suitable for displaying in the field. This allows controlling how value objects passed to setValue are shown to the user, including localization. For instance, for a Ext.form.field.Date, this would control how a Date object passed to setValue would be converted to a String for display in the field.

Related

How to create a display,or similar, method with paramater?

in my myForm I call in a tableMY a displayMethod_fieldA.
In myForm I insered a some date in a DateEdit and I want to make a selection in table using the entered value. If I crete a displayMethod whit parameter I have an error.
Look like this code I get error:
display myEDTField displayMethod_fieldA (date _dateFromForm)
{
tableMY table;
select table
where table.item == this.item
&& table.dateTable == _dateFromForm;
return table.valueFieldA;
}
I have an error looklike this:
The display method has an incorrect parameter profile.
There is another way to display or set the value in my StrinEdit in Grid by method passing a parameter?
In web I saw the method modifier modifierMothod , but I need some more explanation. I don't know if this method is a right way.
Display methods are not designed with this feature.
display method for a table, form, report, or report design does not
have any parameters. For example: display Amount amount()
A display method for a form data source does require a parameter. You
use the
parameter to specify a table buffer. The type of the table buffer has
to match the type of the table in the form data source.
https://msdn.microsoft.com/en-us/library/aa595058.aspx
You can create the desired behaviour with an edit method (and setting the field to AllowEdit(false) or enabled(false).

How to replace a date in a date list using SSJS in XPages

I have a date list field and need to replace a value in the list with another value
so I have this list of type "date list"
The user enter a new value in a date field in the webpage. This new value should be added to in this case the second item in the date list, but it in the real case it should be able to be added to any position in the list
This is the inputfield where user enter a new date
<xp:inputText id="inputText1">
<xp:this.converter>
<xp:convertDateTime pattern="yyyy-MM-dd"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
This is the code I use in my button that should replace the date
doc is a data source on the XPage
var v:java.util.Vector = doc.getDocument().getItemValueDateTimeArray("TDate")
v.setElementAt(getComponent("inputText1").getValue(),1)
doc.replaceItemValue("TDate",v)
doc.save()
Not sure what I am doing wrong here, but I seem to have two problems, first the field only seem to contain one element after I save, and secondly the date that is added contain both date and time, and not only the date
This is the result after running the code
Running the same kind of code using a multivalue "text" field works fine.
how can I modify my code so that my replace operation in the date list works
to set a date value without the time part
get a DateTime object and call the function setAnyTime() on the NDT object and replace the item
to set a specific time value in a multivalue datetime field
get the field you will get a vector with all the datetime object.
Get the specific timedate in the vector change it and set it back to the vector. and after that replace the item

GXT - Pissed off with ComobBox in Grid (different Display Label and Value)

I am trying to add a CobmoBox in EditorGrid
I have a class Vehicle with fields
Integer vehicleId;
String plateNo;
Integer vehicleType; //1=Car,2=Truck
I want the combo box to show vehicle's type in text form i.e if vehicleType is 1, "Car" would be displayed. And when the user select any other option - like "Truck" the corresponding integer value should be populated into the bean.
This is pretty standard stuff with plain old JSP and HTML.
However I couldn't find a simple way the do this in Ext GWT.
If you are using a GXT ComboBox, the easiest way to is create a model representing your vehicle object if you haven't already. This is basically a class that extends GXT's BaseModelData class.
Once you have your model, you create a combo box using that type:
ComboBox<VehicleModel> box = new ComboBox<VehicleModel>();
The last step is to tell the combo box which fields to use for values and for display, which is done with 2 method calls:
box.setDisplayField("field name for display");
box.setValueField("field name for value");
When you load up a store of vehicle models, GXT will take care of the rest. You will, however, need to convert the model back to the vehicle object itself to be persisted.

JasperReports: Changing a Pattern Value based on a Field

I have a field that contains the type of data coming in on the detail fields. It is either an Integer or an Currency value. [An Integer is not a Currency value] The field that is outputing the value is typed as a double, and the text field is currently ####.##.
Is there any way that the pattern can change based on a field value [the field value that makes this either or is a boolean.
Now, at least in version 4.7.1, there is an "Patern Expr."
ex:
$F{Field}.abs().compareTo( new BigDecimal(1) ) < 0 ? "0.0#####E0#" : "#,##0.00"
Every Jasper report can access all classes available on the classpath. Create a static method which will accept an Object as an argument, check if it is Currency or Integer and return well formatted String value. Import the class in the report and invoke the formatting method from the field.

Axapta: Edit form field values

Using a 'clicked' override on a button, I'd like to modify values in an Axapta form.
I'm able to get data from the form field using:
str strOld = Form_FieldName.valueStr();
I'm able to prepend text to the field using:
Form_FieldName.pasteText(strNew);
I can't seem to find a .clear method or .value= method. I'd like to replace the entire value in the field with new information.
Thanks
If the field is bound to a datasource, you have to modify the value in the datasource. If the field is bound to a variable, then modify the value of the variable itself. It is the easy an smart way to do it.
You can modify the value in the form control by using the .text() method. (The control have to be the AutoDeclaration property set to Yes). This is a setter-getter (parameter) type method used in AX. If no parameter is passed, it is user as getter (read). If you pass a value, this is a setter (write).
Hope this helps.