How can I customize a kendo scheduler popup window - kendo-ui

I'm wondering if there is a way to customize the window that pops up when you click on the kendo scheduler. I would like to remove the "all day event" checkbox.

Also consider using CSS:
div[data-container-for='isAllDay'] {
display: none;
}
label[for='isAllDay'] {
display: none;
}

You can do this using templates. The template documentation is very sparce, but I have used this as a trimmmed-down version of the scheduler edit window.
In the MVC razor declaration add .Editable(e => e.TemplateId("editor"))
then add a script to your view that contains the following:
<script id="editor" type="text/x-kendo-template">
<div class="k-edit-label">
<label for="title">Title</label></div>
<div class="k-edit-field" data-container-for="title">
<input type="text" class="k-input k-textbox" name="title" data-bind="value: title"></div>
<div class="k-edit-label">
<label for="start">Start</label></div>
<div class="k-edit-field" data-container-for="start"><span style="display: none;" class="k-widget k-datetimepicker k-header"><span class="k-picker-wrap k-state-default">
<input type="text" data-bind="value: start, invisible: isAllDay" data-role="datetimepicker" data-type="date" required="" name="start" data-timezone="Etc/UTC" style="width: 100%;" class="k-input" role="textbox" aria-haspopup="true" aria-expanded="false" aria-disabled="false" aria-readonly="false" aria-label="Current focused date is 6/10/2013 12:00:00 AM"><span class="k-select" unselectable="on"><span class="k-icon k-i-calendar" unselectable="on" role="button">select</span><span class="k-icon k-i-clock" unselectable="on" role="button">select</span></span></span></span><span style="" class="k-widget k-datepicker k-header"><span class="k-picker-wrap k-state-default"><input type="text" data-bind=" value: start, visible: isAllDay" data-role="datepicker" data-type="date" required="" name="start" data-timezone="Etc/UTC" style="width: 100%;" class="k-input" role="textbox" aria-haspopup="true" aria-expanded="false" aria-disabled="false" aria-readonly="false" aria-label="Current focused date is Monday, June 10, 2013"><span class="k-select" unselectable="on" role="button"><span class="k-icon k-i-calendar" unselectable="on">select</span></span></span></span><span data-bind=" text: startTimezone"></span><span class="k-invalid-msg" data-for="start" style="display: none;"></span></div>
<div class="k-edit-label">
<label for="recurrenceRule">Repeat</label></div>
<div class="k-edit-field" data-container-for="recurrenceRule">
<div data-bind="value: recurrenceRule" name="recurrenceRule" data-role="recurrenceeditor"></div>
</div>
<div class="k-recur-view"></div></script>

You can use the edit event of the scheduler to hide the all day checkbox.
edit: function(e) {
e.container
.find("[name=isAllDay]") // find the all day checkbox
.parent() // get its wrapper
.prev() // get the label wrapper
.remove() // remove the label wrapepr
.end() // get back to the checkbox wrapper
.remove(); // remove the checkbox wrapper
},
Here is a live demo: http://jsbin.com/ibOYUXev/1/edit

If you're looking for a full control over the contents of the editor dialog, you can use template:
template
<script id="editor" type="text/x-kendo-template">
<h3>Edit meeting</h3>
<p>
<label>Title: <input name="title" /></label>
</p>
<p>
<label>Start: <input data-role="datetimepicker" name="start" /></label>
</p>
<p>
<label>Start: <input data-role="datetimepicker" name="end" /></label>
</p>
</script>
scheduler div
<div id="scheduler"></div>
script
<script>
$("#scheduler").kendoScheduler({
date: new Date("2013/6/6"),
editable: {
template: $("#editor").html()
},
views: [
{ type: "day" }
],
dataSource: [
{
id: 1,
start: new Date("2013/6/6 08:00 AM"),
end: new Date("2013/6/6 09:00 AM"),
title: "Interview"
}
]});
</script>

Related

How to keep white spaces in the beginning of string from json response rendered by Kendo DataSource?

DataSource gets json response data:
categoriesDS = new kendo.data.DataSource({
transport: {
read: {
url: "{{ path('get_json_categories') }}",
dataType: "json"
}
}
});
with white spaces:
{"categoryId":33,"parentId":32,"name":" [ ] p1"}
but rendering it without white spaces. How to change this behaviour?
edit: I need whitespaces in select options input. Below is my template script
<script id="popup_editor" type="text/x-kendo-template">
<form method="post" action="{{ path('updatedoc') }}" enctype="multipart/form-data">
<div class="k-edit-label">
<label for="documentFile">Plik</label>
</div>
<div data-container-for="documentFile" class="k-edit-field">
<input name="files" id="files" type="file" aria-label="files"/>
</div>
<input name="documentId" id="documentId" type="text" data-bind="value:documentId" style="display: none;"/>
<div class="k-edit-label">
<label for="documentDateAdd">Data Dodania</label>
</div>
<div class="k-edit-field">
<input type="text" class="k-input k-textbox k-state-disabled" name="documentDateAdd"
data-bind="value:documentDateAdd" disabled>
</div>
<div class="k-edit-label">
<label for="documentDesc">Opis</label>
</div>
<div data-container-for="documentDesc" class="k-edit-field">
<textarea name="documentDesc" class="k-textbox" data-bind="value:documentDesc"></textarea>
</div>
<div class="k-edit-label">
<label for="user">Twórca</label>
</div>
<div data-container-for="user" class="k-edit-field">
<input type="text" class="k-input k-textbox k-state-disabled" name="user" data-bind="value:user"
disabled>
</div>
<!-- dropdownlist-->
<div class="k-edit-label">
<label for="FacultyRankId">Kategoria</label>
</div>
<!-- dropdownlist editor for field: "FacultyRankId" -->
<div class="k-edit-field" id="categoriesDiv">
<input id="categoriesInput" name="categoryId"
{# tu wskazuję z którą wartością z data-source wiązać ten input tj z czym synchronizować, czyli
zmiany w inpucie na które pole ma wpływać z dataSource#}
data-bind="value:categoryId"
data-value-field="categoryId"
{#to co jest wyświetlane w dropdown#}
data-text-field="name"
data-source="categoriesDS"
data-role="dropdownlist"
data-value-primitive="true"
/>
</div>
<script type="text/javascript">
$('.k-edit-buttons:eq(1)').hide();
$("span.k-dropdown-wrap > span.k-input").each(function() {
console.log($(this).text());
var text = $(this).text().replace('PODKATEGORIA666, ', '. .');
$(this).text(text);
});
<\/script>
<div class="k-edit-buttons k-state-default">
<button type="submit" class="k-button k-primary"> Aktualizuj </button>
</div>
</form>
</script>
and style selector that didn't work:
<style>
input#categoriesInput { white-space: pre; }
</style>
(It looks like your post is mostly bar code; please add some more details.It looks like your post is mostly code; )
Try setting white-space style to pre and depending on the widget that you want to use it you will have to use different selectors.
Following an example for showing it in a drop down list:
<style>
span[aria-owns="color_listbox"] { white-space: pre; }
#color-list .k-item { white-space: pre; }
</style>
Following a snippet
$("#color").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: [
{ text: " [ ] Black", value: "1" },
{ text: " [ ] Orange", value: "2" },
{ text: "Grey", value: "3" }
]
});
span[aria-owns="color_listbox"] {
white-space: pre;
}
#color-list .k-item {
white-space: pre;
}
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.221/styles/kendo.bootstrap-v4.min.css" />
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/kendo.all.min.js"></script>
<input id="color" value="1" style="width: 100%;" />

How to debounce/delay showing error message in vee-validate

I am using following versions:
"vue": "^2.1.0",
"vee-validate": "2.0.0-beta.14",
How do I debounce display of an error message.
I tried delay, v-delay and few other in following code but nothing seems to work.
<input type="number" v-validate data-rules="required|numeric" name="number" delay="1800"/>
In earlier version this used to happen via data-vv-delay.
Upgrade to the latest versions of Vue & VeeValidate, then continue using: data-vv-delay:
Vue.use(VeeValidate)
new Vue({
el: '#app',
})
.is-error {
border: 2px solid red;
}
.form-group {
margin-top: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.3/vue.js"></script>
<script src="https://cdn.jsdelivr.net/vee-validate/2.0.0-beta.17/vee-validate.js"></script>
<div id="app">
<div class="form-group">
<label class="label" for="email">Email</label>
<input
v-validate
data-vv-rules="required|email"
:class="{'is-error': errors.has('email') }"
name="email"
type="text"
data-vv-delay="2000"
placeholder="Email">
<span v-show="errors.has('email')">
{{ errors.first('email') }}
</span>
</div>
<div class="form-group">
<label class="label" for="number">Number</label>
<input
v-validate
data-vv-rules="required|numeric"
:class="{'is-error': errors.has('number') }"
name="number"
type="number"
data-vv-delay="2000"
placeholder="Number">
<span v-show="errors.has('number')">
{{ errors.first('number') }}
</span>
</div>
</div>
The above snippet threw some errors when using your version (Vue 2.1.0 & VeeValidate beta 14). The issue seems to lie with beta 14 being a bit dodgy!

how to stop form submition on enter key?

I don't want to submit form.
When I press enter on textbox my form is submited and reloaded automatically.
How to stop submiting form?
My code is.
<form class="cart" id="cart-frm" style="margin-bottom: 10px; ">
<div class="row">
<div class="quantity col-md-6 col-sm-6 col-xs-6" style="width:auto;" >
<label style="float: left; margin-top: 10px" for="quantity">Quantity : </label>
<span> </span>
<input style="float: right;" type="text" class="input-text qty" id='qty' title="Qty" value="1" name="quantity" min="1" step="1">
</div>
<div class="quantity col-md-6 col-sm-6 col-xs-6 pull-right">
<button type="button" style="float: right;" id ='<?php echo $product['id']; ?>' class="btn btn-primary btn-icon add-to-cart-product"> Add to cart</button>
</div><br>
</div>
<span class="clearfix"></span>
</form>
<script type="text/javascript">
document.getElementById("cart-frm").onsubmit = function(){
// if needs to be submited - return true
// else - return false
return false;
};
</script>

how to can I use element name including dot for jQuery form valiator plugin

I am using jQuery and form validator plugin and it works fine except one page shown below.
HTML:
<form method="POST" enctype="multipart/form-data" id="frmReg" class="form-horizontal" novalidate="novalidate">
<input type="hidden" name="mode" id="mode" value="insert">
<input type="hidden" name="fileName" id="fileName">
<div class="control-group">
<label id="fileLabel" class="control-label">*File Name</label>
<div class="controls">
<input type="file" name="file" id="file" placeholder="Select file" required="required" class="valid">
</div>
</div>
<div class="control-group">
<label class="control-label">*Package Name</label>
<div class="controls">
<input type="text" name="id.appId" id="appId" placeholder="Type group ID" tabindex="0" class="valid">
</div>
</div>
<div class="control-group">
<label class="control-label">*Application Title</label>
<div class="controls">
<input type="text" name="appName" id="appName" placeholder="Type application name" class="valid">
</div>
</div>
<div class="control-group">
<label class="control-label">*Version</label>
<div class="controls">
**<input type="text" name="id.version" id="version" placeholder="Type version" tabindex="0" class="valid">**
</div>
</div>
<div class="control-group">
<label class="control-label">Description</label>
<div class="controls">
<textarea name="description" id="description" placeholder="Type description" class="valid"></textarea>
</div>
</div>
<div class="modal-footer">
<button aria-hidden="true" data-dismiss="modal" class="btn">Close</button>
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</form>
JS:
$("#frmReg").validate({
ignore: "", //for hidden field
rules: {
version: {
required: true,
number: true
}
},
messages: {
version: {
required: "Enter version number",
number: "Decimal numbers only allowed."
}
}
});
**$("#frmReg").validate().element("#version");**
It works when I use 'version' as the input name but I have to use 'id.version' as input name rather than 'version' because of server-side framework. But when I use the name, the validation code always returns true, even when I type any special characters and alphabets.
How can I still use id.version for the element?
Your answer would be appreciated.
As per the documentation...
Fields with complex names (brackets, dots)
If your form consists of fields using names that aren't legal JavaScript identifiers, you have to quote those names when using the rules option
Simply put quotes around the name containing dots...
$("#frmReg").validate({
ignore: "", //for hidden field
rules: {
'id.version': {
required: true,
number: true
}
},
messages: {
'id.version': {
required: "Enter version number",
number: "Decimal numbers only allowed."
}
}
});
Working DEMO: http://jsfiddle.net/A2ZdL/

how to highlight invalid section — twitter bootstrap/jquery/validate plugin

I have a form in twitter bootstrap:
<div class="form-div">
<form id="fvujq-form1" method="post" action="">
<div class="control-group name">
<fieldset>
<label>Name *</label>
<input type="text" name="name">
</fieldset>
</div>
<div class="control-group email">
<fieldset>
<label>E-Mail *</label>
<input type="text" name="email">
</fieldset>
</div>
<div class="control-group comment">
<fieldset>
<label>Your comment *</label>
<textarea name="comment"></textarea>
</fieldset>
</div>
<button class="btn btn-primary">Submit</button>
</form>
</div>
and this is how I validate it with bassistance Validate plugin:
$(document).ready(function() {
$("#fvujq-form1").validate({
submitHandler:function(form) {
SubmittingForm();
},
success: function(label) {
label.html("✔").addClass("valid");
},
onfocusout: function(element) { $(element).valid(); },
focusInvalid: false,
highlight: function(element, errorClass, validClass) {
$('.form-div').find('.control-group' + element.id).addClass('error');
},
unhighlight: function(element, errorClass, validClass) {
$('.form-div').find('.control-group' + element.id).removeClass('error');
},
errorClass: "help-inline",
errorElement: "strong"
I want to add .error to the div currently validated, but this code adds class to every .control-group occurence, not only validated one :(
thx 4 yr help.
JSFiddler Example
This will validate as you leave each field or when you hit the submit button all fields that meet the rules will present errors.
HTML
<form action="" id="fvujq-form1" class="form-horizontal">
<fieldset>
<div class="control-group">
<label class="control-label" for="name">Your Name</label>
<div class="controls">
<input type="text" class="input-xlarge" name="name" id="name">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email Address</label>
<div class="controls">
<input type="text" class="input-xlarge" name="email" id="email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="comment">Comment</label>
<div class="controls">
<input type="text" class="input-xlarge" name="comment" id="comment">
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</fieldset>
</form>
Javascript
$(document).ready(function(){
$('#fvujq-form1').validate(
{
rules: {
name: {
minlength: 2,
required: true
},
email: {
required: true,
email: true
},
comment: {
minlength: 2,
required: true
},
},
highlight: function(element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function(element) {
element
.text('OK!').addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
}
});
});

Resources