Default Select list value in Combo box - LWC - salesforce

I have created a combo-box in LWC for which, I want to default a value.The options for the LWC are fetched from controller. I tried the following & it dint work. I have removed the "placeholder="-Select-", but still OOB i see a place holder "Select a value". I want to remove the OOB placeholder & also default it to a particular value on load.
<lightning-combobox required
label="Values"
class="value"
value={choosenValue}
options={choosenValueOptions}
onchange={handleValueChange} >
</lightning-combobox>
TIA,
Sunil

Add in the Javascript code the default value:
export default class ComboboxBasic extends LightningElement {
#track chosenValue = 'defautValue';
...
}

Related

Customize export filename of Wagtail report?

Is there a way to customize the export filename for reports that are added to the Reports menu in the same way that export_filename = "xxxxxxx" works for ModelAdmin? (ModelAdmin link)
Override the get_filename method on your PageReportView subclass. Wagtail's built-in reports do this as follows:
class LockedPagesView(PageReportView):
# ...
def get_filename(self):
return "locked-pages-report-{}".format(
datetime.datetime.today().strftime("%Y-%m-%d")
)

Vaadin 7 -> com.vaadin.ui.CheckBox -> ".getValue()" does always return "false"

I use a Vaadin7 com.vaadin.ui.CheckBox with Java 1.8 on a Wildfly Application Server.
I have a PopUpDialog with the following checkbox configuration:
checkBox1.addValueChangeListener(event -> // Java 8
LOGGER.info("property Value: "+ event.getProperty().getValue().toString()+
" getValue Value: "+checkBox1.getValue()));
When I click the checkBox1 in the User Interface in the WebBrowser the ValueChangeListener gets called.
The first property Value "event.getProperty().getValue().toString()" returns the correct true/false state of the checkbox.
But the checkBox1.getValue() which I want to use in my PopUpDialog class methods to access the true/false == clicked/not clicked state of the checkobox returns always false even if I call it in the ValueChangeListener
Can someone help me why the "getValue()" method does not return the correct state ?
-----------------EDIT---------------
One solution is to use the ValueChangeListener to set the value of the Checkbox:
checkBox1.addValueChangeListener(event ->
checkBox1.setValue(
(Boolean) event.getProperty().getValue()
));
But normally the value should be set without a listener setting it manually, correct ?
what is a PopUpDialog class? Is it some add-on? (Haven't found myself by briefly googling)
I've tried your scenario with a PopupView and value is always returned correctly. Vaadin version is 7.7.13
CheckBox cb=new CheckBox();
cb.addValueChangeListener(e->{
System.out.println("Event value" + e.getProperty().getValue());
System.out.println("cb value: " + cb.getValue());
});
VerticalLayout popupContent = new VerticalLayout();
Button getValue=new Button("Value", e->{
Notification.show("CB value:" + cb.getValue());
});
popupContent.addComponents(cb,getValue);
PopupView popup = new PopupView("Pop it up", popupContent);
layout.addComponent(popup);
setContent(layout);
Is there anything I've missed in my example?
Edit: And Checkbox, of course, should return a correct value. Otherwise, it's a bug

prompt text won't disappear after selecting one of the suggested options

I have implemented react-select to allow entering tags based on auto-complete suggestions and/or inserting new ones.
My implementation is as follows:
import Select from 'react-select';
...
<Select.AsyncCreatable
className='add-tags'
clearable={!!selectionTags}
placeholder={'add more'}
name="form-field-name"
value={selectionTags}
onChange={setSelectionTags}
loadOptions={loadOptions}
promptTextCreator={(label)=>`add new tag: ${label}`}
inputProps={inputProps}
multi
/>
When selectionTags is the list of tags that have already been selected, setSelectionTags is a function that adds a new selected item to that list, and loadOptions holds the list of autocomplete suggestions.
Problem is that if I type "ta" and I have "tag1" as one of the available completions, then choosing it will empty the list of suggestions but leave the "add new tag: ta" entry displayed.
Any idea why it's not being removed as well?
Thanks!
Following this thread on React-Select github:
https://github.com/JedWatson/react-select/issues/1663
I ended up working round it by adding the following options:
ref={s => (selectRef = s)} // store a reference to the select instance
onChange={tags => {
selectRef.select.closeMenu(); // close the entire menu
selectRef.select.setState({
isFocused: false, // remove focus from new tag option
});
setSelectionTags(tags); // call the add tags method with the new set of tags
}}

How can add new field to an event with dhtmlx scheduler?

I want to add new fields or propierties to an calendar event. How can I do it?
Thanks!
You need to
add new section to lightbox form
http://docs.dhtmlx.com/doku.php?id=dhtmlxscheduler:details_form
for new section of lightbox, set map_to value as name of new field
on server side add extra field to the list of fields in render command
This is how you would create a simple href link inside an event:
1) Go to the Event Configuration Console and create a custom field, under the section that says 'CUSTOM FIELD'. Give the field a name. In this example, call it 'url'. Select its type as 'TextArea'.
2) Create another custom field, call it 'link_title'.Also a 'TextArea'. Description is optional.
SAVE
3) Go to the 'Templates' section of the event console. Under the first section (... scheduler.templates.event_text=function(start,end,event){... ) where you can input text, put ->
return "<b> "+event.text+"</b><br><br>" + event.link_title + "";
SAVE
When you go to create your event from the main calendar, you will see extra fields. Type in them, save your event, and voila. Toot Sweet.
What do you mean by calendar event?
Is it adding a new event?, then it must be done using lightbox(built-in option)
scheduler.config.lightbox.sections=[
{ name:"description", height:50, map_to:"text", type:"textarea", focus:true },
{ name:"location", height:43, map_to:"event_location", type:"textarea",
default_value:"Blackheath Avenue London,Greenwich,Greater London SE10 8XJ,UK"},
{name:"recurring", height:115, type:"recurring", map_to:"rec_type",
button:"recurring"},
{ name:"time", height:72, type:"time", map_to:"auto"}
];
each tag used in here is suppoted by the plugin,,,,in you want to have a seperate customize lightbox go to
http://docs.dhtmlx.com/scheduler/custom_details_form.html
This is the preview

Django Admin error out that a field that is missing from the form

Getting an error with my admin.py file:
'BaseAdmin.fieldsets[1][1]['fields']' refers to field 'publish_on' that is missing from the form.
my class looks like:
class Base(models.Model):
...
publish_on = models.DateTimeField(auto_now=True, db_index=True)
...
My admin.py looks like:
class BaseAdmin(admin.ModelAdmin):
...
fieldsets = [
('Dates', {
'fields': ('publish_on',)
}),
]
if I change out my admin class with 'pass' or just register with the model class then the date time field shows up.
This error is caused by auto_now and also by auto_now_add. To remedy that add
readonly_fields = ("publish_on",)
in your BaseAdmin (only in django 1.2 and newer).
If you do want to use auto_now_add, but then leave open the possibility of changing the date, you could use default=datetime.now in the model field. This sets a default in the admin, but lets the user change it, and it works in inlines.

Resources