I Have this Form
class MyModelForm(forms.ModelForm):
boolfield = forms.TypedChoiceField(coerce=bool,
choices=((False, 'No'), (True, 'Yes')),
widget=forms.RadioSelect
)
class Meta:
model = MyModel
How can I show the buttons without LI an UL tags ? (I want to show them together horizontally), and how to set False selected by default? ()
Setting the initial property on the field should select False.
You can also custom render the field to display them how you want. You could also define a new widget, but I don't have a link handy for that.
Related
I'm adding a new fields to my views through my custom module.
When I open up the views page UI, the field is not show up. However, If I edit the view on UI and click add field, I can see my custom field is available to add.
My question, how can I add automatically that field to the list of fields to display on the views?
function mymodule_views_default_views() {
...
$handler->display->display_options['fields']['myfield']['id'] = 'fieldname';
$handler->display->display_options['fields']['myfield']['table'] = 'databaseTableName';
$handler->display->display_options['fields']['myfield']['field'] = 'fieldname';
...
}
In CKEditor, I have a textfield (given by the Forms plugin).
How can I get its value? Also, how can I enumerate all the textfields?
If you using jquery:
$('textarea.CKEditorClass').each(function() {
//enumerate
});
CKEditorClass is class of element textfields
or just get quantity
$('textarea.CKEditorClass').length
For get content
CKEDITOR.instances[id].getData();
id is id of element textfield
I am completely new to Nativescript, I am trying to add class Name dynamically to a gridlayout on tap.
I am not using Angular 2.
How to access the grid layout element and add class name to the same.
All that you need to do is search for the desired element in the UI tree for example by accessing the parent of the Button or by setting an id to the element and using the .getViewById() method of the root of the Page or the Page itself.
Finally in order to set the css class of that View simply set its className property, something like this:
export function onChangeCssClassButtonTap(args) {
var button = args.object as Button;
var parentGridLayout = button.parent as StackLayout;
parentGridLayout.className = "myGridCssClassName";
}
Here are some documentation articles that may be useful to you:
Finding View by its id
Styling in NativeScript
I am using Kendo Numeric text box to display decimal values.I want to change the font color based on the user input.How to achieve this?
You Can do this in JQuery easily by changing the style on the change and spin event of the input:
On your numeric text box add the events:
$("#numerictextbox").kendoNumericTextBox(
{
change: onChangeOrSpin,
spin: onChangeOrSpin
});
Then in the event handler call:
function onChangeOrSpin()
{
var val = this.value();
changeFontColour(val);
}
function changeFontColour(val)
{
if(val < 5)
{
$("#numerictextbox, .k-input").css('font-family','Arial');
$("#numerictextbox, .k-input").css('font-style','italic');
$("#numerictextbox, .k-input").css('font-weight','bold');
$("#numerictextbox, .k-input").css('color','blue');
}
else
{
$("#numerictextbox, .k-input").css('font-family','Times New Roman');
$("#numerictextbox, .k-input").css('font-style','normal');
$("#numerictextbox, .k-input").css('font-weight','normal');
$("#numerictextbox, .k-input").css('color','black');
}
}
Here is a working fiddle: http://jsfiddle.net/loanburger/nwsw4yeq/
Update:
For multiple numeric inputs on the same page, use classes and add a different class to each input so you can distinguish between then when you need to change the colour. Then use a data attribute to find the correct one to change.
You cannot use the id because there are two parts to how kendo creates the widget:
The first part is the input for editing the value. This is the
one the user interacts with. This input will be given the class:
numerictextbox numericOne k-input
There is a second input of interest which is the one used to display the value after the widget looses focus this one gets the classes: k-formatted-value numerictextbox numericOne k-input
Neither of these inputs get an id and you don't want to use the native Kendo classes either so using a distinct class on each of your numeric widget controls, you can identify which colours to change since that class will get added to both inputs in the widget.
See here: https://jsfiddle.net/loanburger/4evy3tcg/
I have a long form to test, so I created a CompleteForm() helper method to complete the form. To test the validations, I am calling CompleteForm() and then making the field I want to test invalid. Can't figure out how to uncheck the radiobuttons.
Just set the Checked property of the RadioButton object to false
To uncheck all the radio buttons on a page you could do:
foreach(RadioButton rb in ie.RadioButtons)
{
rb.Checked = false
}