I'm using the Add Form to add records to my JQGrid. One of the fields is a checkbox. Does anyone know how to have the checkbox to be defaulted to checked when the form displays. I thought it would use the onInitializeForm event and the setCell method but I'm having no luck. Thanks.
Found it:
beforeShowForm: function(eparams) {
document.getElementById('calc_next_svc').checked = 'true';
}
}, // add options
Related
Case:
I have an array of answers which I want to show in the view as radio inputs. When one of the answers is already answered it must be [checked] and if it's [checked] a textarea shows, so far so good.
Next I want to check another radio input and I want the current selected to be deselected and its textarea hidden, then the new selected radio input should be [checked] and it's textarea should show.
I use the FormBuilder and FormArray and have following issues.
I can't use index without intrapolation, I see many examples where the index is used without.
If I select another radio input, first my data disappears and it's not checked and on the second click it get's checked but now both are checked.
- I don't have access to the checked event, I can show it in the view with {{tempVar.checked}} as you can see above, if I use a template variable #tempVar, but I don't have access to it in the textarea below *ngIf="tempVar.checked". If I do use it in the ngIf I get the following error
Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.
Questions:
Is this the right approach?
An example of a Reactive Dynamic form with FormBuilder and FormArray with Radio inputs
Here is my code
https://gist.github.com/webwizart/121c85a0f316f47977cc0c99455af7bf
I would think using the tags should be reserved for unique identifiers? I wouldn't be surprised if dom renderer will update all elements with the same id.
Not sure if this will help, but you could use an answer view model instead (containing the same data) but that also has a 'checked' property
This way you can be sure that it will behave as you would expect.
e.g.: (in your component.ts)
let answers = this.question.Question.PossibleAnswers
.map(a =>
{ return Object.assign({}, a, { checked: false });
}
);
then in html you use: 'answer.checked' instead of 'radio.checked'
ps: also you could use ng-container instead of span, so you don't have an extra DOM imprint in your html
Can anyone suggest a link or solution to add select All option within the multiselect dom element of the material design. I want all the options to be selected except for the select all option and want to display it in the text field and post it.
I couldn't find a solution for it. Can anyone suggest.
Pls Note: I dont want to add it as a button outside the dom.
$("#all_member").change(function(){
if($("#all_member option[value=-1]:selected").length > 0){
$('#all_member option').attr('selected', "selected");
$('#all_member').prev("ul").find("li").addClass('active');
$('#all_member').prev("ul").find("li span input").attr('checked', "true");
}else{
$('#all_member option').attr('selected', "false");
$('#all_member').prev("ul").find("li").removeClass('active');
$('#all_member').prev("ul").find("li span input").removeAttr('checked');
}
Thanks IN advance!
I can provide the logic. The rest is up to you.
Put an onChange event handler (function) for your select.
On that function, put an "if statement" to check if the value is equal to the value of "Select All" option.
If it returns true, then manually call the element and set its value to the value of all the other options (probably an array).
Imagine I have an unordered list with 2 cols, col 1 is the name of a file and col 2 is a pencil icon which has tooltip enabled. When the user clicks on this pencil icon, it opens a tooltip which contains a form. In this form the user will enter a new file and the value will be validated.
When the tooltip is shown, I attach jQuery validator to the form inside the tooltip. The problem is that each time the tooltip is shown, a new validator is attached. I would like to only attach one validator to a form. How can I successfully check if validator already exists for a form?
var validator = forms.validate();
console.log(validator);
// always evaluate to true
if (validator) {
}
This doesn't seem to work. Does anyone have any ideas?
You can use the jQuery data to check if the validator exists on a form element like this:
var form = $('#myform');
if(form.data('validator')){
// validator exists
}
I realized that I could just check to see if a form has the class "novalidate" to determine if the form has a validator attached or not.
var forms = jQuery("form.edit");
if (forms.attr("novalidate")) {
return;
}
I need to add a dropdown in the New Ticket Screen of OTRS. I managed to add a Dropdown by adding a Dynamic Field with the help of Dynamic Fields Management in Admin Section.
Now my problem is that I want to populate this Dropdown with data that I get from some distant database on the run and dependin on the User Loged In. How can i feed In this Dynamic Data in the DropDown List in OTRS ?
Thank you.
To do such a thing I do not believe is supported from the Dynamic Field UI provided by OTRS.
So you can either:
1- add all the possible values into the drop down box and then hide/show them using code changes in the dtl file. (use javascript).
For creating a new ticket there is either AgentTicketEmail.dtl or AgentTicketPhone.dtl.
There is also the CustomerTicketMessage.dtl if you want to include it in the customer interface too.
2- Add only one value which you can also hide using javascript in the dtl files and just add values to the dropdown list using javascript code.
Example javascript below hides/shows different dynamic fields. You can find what your dynamic field is called by looking at the page source from your browser.
function setdynamicviews(){
switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
case "8\|\|Support": // need to slash escape the pipes
//show dynamic fields
document.getElementById('LabelDynamicField_Product').style.display = 'block';
document.getElementById('LabelDynamicField_SerialNo').style.display = 'block';
break;
default:
//hide dynamic fields.
document.getElementById('LabelDynamicField_Product').style.display = 'none';
document.getElementById('LabelDynamicField_SerialNo').style.display = 'none';
}
}
To add items to usign javascript see here
Yuu have not provided enough information for me to help with getting the information "from some distant database"
Note: if you do change any DTL files or other otrs files you should defrinitely create a theme first see here
Hope this helps.
My situation is: Im making a simple inbox page. The inbox is a listing made from a DevExpress grid. Each row in the grid has a checkbox that the user can check so that they can multi delete records (similar to yahoo mail etc).
When the user clicks the select all link or the clear all link i need to set all the checkboxes within the grid to be checked or unchecked. How do I go about this with client-side scripting? Thanks
The easiest way to do this is to use jQuery. With the right selector it's pretty much a one liner. I don't know how much you know about jQuery so here's a link to the selector docs if you want to read up:
http://api.jquery.com/category/selectors/
The selector will depend on the layout of your page. I've done it before using something like this:
$("#tableId tr td input:checkbox").attr("checked", true);
In this example all checkboxes within a table with an id of "tableId" are checked
Using jquery it should be pretty easy- assuming you can use one of the selectors to select all of the checkboxes (take a look at the different jquery selectors http://api.jquery.com/category/selectors/).
Attach a toggle handler:
$('Selector for the "select all" checkbox>').toggle(function() {
alert('First handler for .toggle() called.');
}, function() {
alert('Second handler for .toggle() called.');
});
Select all checkboxes and when toggled switch the checked state of the other checkboxes:
$('<Selector for the ones you want to toggle>').attr('checked', true);
Provide some sample HTML, or a link to a page, if you need further help.
So putting it together, assuming your "select all" checkbox had an ID of "uxSelectAll" and the ones you want to change have a CSS class of "checkbox-mail-items" it would be something like:
$('#uxSelectAll').toggle(function() {
$('.checkbox-mail-items').attr('checked', true);
}, function() {
$('.checkbox-mail-items').attr('checked', false);
});
you can create a delegate (jquery) for all the checkboxes once you've done the answer above. with something like to perform an action for each check box:
$('div.myGridDivClass tbody').delegate(':checkbox', 'click', function(){
var $checkedRow = $(this), $row = $checkedRow.closest('tr')
// check row is checked
// toggleclass for checked css class and apply to the $row or whatever u want
// do something here
});