Reset or clear all selection of a widget property when it become invisible - properties

In my widget I am making some properties of the widget visible or non visible according to user selection. For example I have a property X which have some check boxes and will only be visible on a certain condition. If I have selected a property Y that should make property X visible and I selected one check box from property X. It fine till now but if I un select that property Y this make property X invisible, but the check box from property X remains checked. How do I make all selection clear when Property X is invisible ?
I am using Kentico 10

I have run into this issue before and I don't believe it is possible.
My solution is to wrap Property X (in my transformation or web part code where this value is displayed) with an if statement based on the value of Property Y (which is a boolean in this case).
In a Text/XML transformation, this would look like:
{% if (ToBool(PropertyY, false)) %}
<div>{% PropertyX %}</div>
{% } else { %}
<!-- Don't use property X's value -->
{% } #%}
In a custom web part code behind file:
if (ValidationHelper.GetBoolean(GetValue("PropertyY"), false))
{
// Property Y is true
// use Property X's value here
}
else
{
// Property Y is false
// Don't use Property X's value here
}

Related

Validate if checkbox is checked depending on another validation in vuelidate

I'm just starting with Vue and vuelidate. I have a form which shall work in the following way:
The form shows a Yes/No radio button group.
If the radio button "Yes" is selected then the form shows a checkbox.
The submit button for the form shall be enabled if one of the following conditions is true:
The radio button is set to "No". OR
The radio button is set to "Yes" AND the checkbox is checked.
I'm having trouble with the conditions described in 3. My current validation looks like this:
termsAccepted: { checked: value => value === true }
This basically works for case 3.2 but not for 3.1. In that case the form is still disabled.
b-form-checkbox#termsAccepted(
v-model="termsAccepted"
:state="!$v.termsAccepted.$invalid"
:disabled="disableForm"
)
Thats sound like a computed property should to the job:
Computed Property Documentation
You could do something like:
computed: {
isEnabled() {
return !radiobutton || (radiobutton && checkbox.checked)
}
}

How to set custom colors for Odoo 12 calendar view events?

There is a good tutorial on how to achieve this in Odoo-8 here:
Tutorial , but it doesn't work on Odoo-12.
Odoo natively allows you to set a field of your model as a basis for color differentiation in calendar view.
<calendar ... color="your_model_field">
The problem is that he will decide automagically what color to assign to every value.
I need to be able to decide what color mapping to use.
Doing some diving in the web module js files, more specifically on
web/static/src/js/views/calendar/calendar_renderer.js on line 266
I found a promising function which appears to be the one responsible for deciding which color to set.
getColor: function (key) {
if (!key) {
return;
}
if (this.color_map[key]) {
return this.color_map[key];
}
// check if the key is a css color
if (typeof key === 'string' && key.match(/^((#[A-F0-9]{3})|(#[A-F0-9]{6})|((hsl|rgb)a?\(\s*(?:(\s*\d{1,3}%?\s*),?){3}(\s*,[0-9.]{1,4})?\))|)$/i)) {
return this.color_map[key] = key;
}
var index = (((_.keys(this.color_map).length + 1) * 5) % 24) + 1;
this.color_map[key] = index;
return index;
},
This function is fed the value of your field (for every calendar event) and returns the color to be used "supposedly" as background for the calendar event square.
According to the second if statement, if you manage to instantiate the CalendarRenderer class with a color_map object which has the possible values of your field as keys and color codes as values you should be ok.
According the the third if statement, if the values of your field are strings with color codes (#FFF, rgb(x, y, z) , etc) they will be set in the color_map object and returned to be used as background colors.
The last part I guess is how odoo decides on a color when no mapping is provided.
I tried both approaches with the same efect:
Image displaying the calendar view
Namely, all the calendar events are rendered with the default color taken from the fullcalendar.css stylesheet (line 529), but the color reference displays correctly on the sidebar to the right.
I would appreciate any light shed on this matter, It has to be possible to make this work!.
Thanks.

Initialize the textfields in Sencha touch 2

I have a sencha touch form, which has two textfields. I want to assign some text to them on page load. I tried setting values in init and launch functions. But in those function textfield are not available, they are undefined. So which event should be used for this purpose?
Either set the values with the setRecord({textFieldName1: "value", textFieldName2: "value"}) method of the container, or assign an id to the text fields and access them via Ext.getCmp('textFieldName').setValue("value") in the initializemethod of the container.
Can't you use the value property directly ? Setting the value will make the textfield fill with the corresponding value of value property i.e in our case, "Sample Text 1" etc ..
e.g
{
xtype:'textfield,
value:'Sample Text 1 ',
},
{
xtype:'textfield,
value:'Sample Text 2 ',
}

On demand color set of rows in SmartClient (TreeGrid)

I have a TreeGrid in SmartClient. Now I want to color some set of lines like line numbers 3-5, 7-11 etc. I am using an external button which passes the values to the SmartClient. Can anybody tell me how to do that? A button is passing the value and it's working fine. But the problem is, where to get the value in SmartClient and how can I color that set of lines.
Since TreeGrid is a ListGrid, I would imagine you could override the getCellStyle function and set the colors as you see necessary.
http://www.smartclient.com/docs/8.1/a/b/c/go.html#search=getcellstyle
So basically in pseudo code:
if (row >= 3 and row <=5)
return "style1"
if (row >= 7 and row <=11)
return "style2"
else
return this.baseStyle
where style1 and 2 are defined in css
And how to custom and keep states with using specific style name (myStyle) like :
myStyle
myStyleDark
myStyleOver
myStyleOverDark
myStyleSelected
myStyleSelectedDark
myStyleSelectedOver
myStyleSelectedOverDark
myStyleDisabled
myStyleDisabledDark
I try to use #Override of getCellStyle
for returning "myStyleA" or "myStyleB"
which i want conserve dynamics suffixs : "Dark", "Over", "Selected", ...
An idea ?...
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/ListGrid.html
The state of the record is indicated by adding a suffix to the base style.
There are four independent boolean states, which are combined in the order given:
"Disabled" : whether the cell is disabled; enable by setting the "enabled" flag on record returned by getCellRecord
"Selected" : whether cell is selected; enable by passing a Selection object as "selection"
"Over" : mouse is over this cell; enable with showRollovers
"Dark" : alternating color bands; enable with alternateRowStyles

How to get Checked CheckBox tag value in Vb.Net?

I have grouped some checkbox in GroupBox1, 2, 3 respectively. Now I want to know the tag value ( I am using a TAG property to assign a some value to radio button ) of check box which is checked in either of the groupboxes.
Is there any solution besides using if then statements?
Iterate over the group box components and check which ones are check boxes. Afterwards, check their Checked state, or whatever you want to do.
C# example:
foreach (Control c in groupBox1.Controls)
{
if (c is CheckBox && ((CheckBox)c).Checked)
{
// whatever
}
}
VB.NET example :
For Each c As Control In groupBox1.Controls
If TypeOf c Is CheckBox AndAlso DirectCast(c, CheckBox).Checked Then
' Whatever
End If
Next