I want to disable previous date and show only present and future dates. I need only datetimepicker. Not datepicker. I applied this method
$(function() {
$( "#datepicker" ).datetimepicker({ minDate: 0});
});
Use the following options:
//beforeShowDay: $.datepicker.noWeekends, //optional
constrainInput: true, // restrict keyboard input
minDate: '+1d' // set minimum date to tomorrow
I am new to jquery and Jqgrid. I have problems displaying an alert message, when the checkbox is not selected in jqgrid, i.e i have declared the multiselect:true.
function initJqGridSearchSubProject(table,pager,msg,loadSelID,caption,chkMrk ){
$(table).empty();
$(table).GridUnload();
var mygrid =jQuery(table).jqGrid({
datatype: "local",
data:msg,
width: 1240,
scrollOffset:0,
height: 250,
colNames:['ID','PID','Project Folder Name','Sub Project Name','Responsible','Status','Last Updated On'],
colModel:[
{name:'id',index:'id',hidden:true, width:5, sorttype:"int", editable: false,resizable:false},
{name:'pid',hidden:true, width:5, sorttype:"int", editable: false,resizable:false},
{name:'projectFolderName', width:250, editable: true,formatter:'tsLinks'},
{name:'subProjectName', width:250, editable: true,formatter:'subProjectLinks'},
{name:'responsible', width:200, editable:false,resizable:false},
{name:'status', width:100,editable: true,stype:'select',edittype:"select",resizable:false,editoptions:{value:"ACTIVE:ACTIVE;INACTIVE:INACTIVE;DELETED:DELETED",readonly:false},editrules:{edithidden:false}},
{name:'lastUpdatedOn', width:200,editable: false,resizable:false,sorttype:'date',formatter:'date',formatoptions:{ srcformat: 'M d y H:i:s', newformat: 'd M y h:i A' }}
],
pager: pager,
rowNum:200,
rowList:[200,400,600,1000],
//rowTotal:2000,
//loadOnce:true,
//rownumbers:true,
gridview : true,
//sortname: 'lastUpdatedOn',
viewrecords: true,
//sortorder: "desc",
toppager:true,
multiselect:true,
singleselect: false,
//multiboxonly:true,
//toolbar: [true,'both'],
caption:caption,
hidegrid: false,
gridComplete:function(id){
//$(chkMrk).hide();
//alert('grid complete');
},
beforeSelectRow: function(rowid, e)
{
// reset check box selection only when user clicks on another checkbox
if($(e.target).is("input:checkbox"))
{
// reset/clear other checkboxes selection before making a latest clicked row's checkbox as selected
jQuery(table).jqGrid('resetSelection');
}
// Code To Disable Check Box Selection When User Selects by Clicking on A Row
return $(e.target).is("input:checkbox");
//return(true);
}
});
jQuery(table).jqGrid('navGrid',pager,{del:false,add:false,edit:false,search:false,refresh:true,cloneToTop:true,afterRefresh:function(){}},{},{},{},{});
jQuery(table).jqGrid('navButtonAdd', table+ '_toppager_left',{caption:"Add WO", buttonicon:"ui-icon ui-icon-plus",id:"SUBPROJID", onClickButton: function(){},position:"first",title:"Add WO"});
});
This is my whole code jqgrid...
I have a rows of fields with prjt names and subprjects names, where i use multiselect, to display the checkbox before the row for all fields, Its mandate that user should click one checkbox to show other page,where if user does not check, he should be shown an alert message to check any checkbox.
I hope that I undertand correct your requirements. You added custom button "Add WO" to the navigator bar and you need display alert message if no row is selected when the button are clicked or to redirect to another page if some row is do selected.
You can get the list of selected rows using $(this).jqGrid("getGridParam", "selarrrow") or using $(this).jqGrid("getGridParam", "selrow") inside of onClickButton, which will be called if the user click on the button. The internal parameter selrow represent the rowid of last selected row. If $(this).jqGrid("getGridParam", "selrow") is null then no row is selected. The call $(this).jqGrid("getGridParam", "selarrrow") get the value of another internal parameter "selarrrow" which is array of selected ids. If will be filled in case of usage multiselect:true.
So I think that you can display warning to the user if selrow is null or if selarrrow is empty array. If the need to redirect to another HTML page you can assign new value to location.href.
Use this in last line to uncheck last selected check box
jQuery(this).attr('checked', false);
Full code
jQuery(document).ready(function(){
jQuery('input:checkbox').change(
function(){
if (jQuery('input:checkbox:checked').length == jQuery('input:checkbox').length){
alert('Alert Text.');
jQuery(this).attr('checked', false);
}
});
});
i've got the following code taken and slightly modified by the original example page:
http://jsfiddle.net/zK3Wc/21/
somehow, if you use the arrow down button to go through the list, it shows the values (digits) in the search field, instead of the label, but the code says, that on the select event, the label should be set as the value.
what i would need is to display the label in the searchfield instead of the digits, but if i click on an item, it has the digit value in the url, the same when using the arrow down button.
Ramo
Add a focus event:
focus: function( event, ui ) {
$( ".project" ).val( ui.item.label );
return false;
},
http://jsfiddle.net/zK3Wc/26/
For me, I forgot to put return false; in the select: callback function
I've run into a conflict between javascript tools and my knowledge of javascript isn't quite advanced enough to solve it.
I'm using drupal's editablefields module to allow users to edit fields inline in the node views as apposed to editing them in node/%/edit.
Combined with this i'm using François Gélinas' jquery-ui-timepicker: http://fgelinas.com/code/timepicker/
The problem i run into is this, when called initially the timepicker is bineded to a dom element, for example:
#edit-field-days-start-time-und-0-value
using code like this:
$('#edit-field-days-start-time-und-0-value').timepicker();
This works great, and the timepicker pops up when the user clicks in the field, and they can click on a new hour it will update the field. But as soon as that update happens drupal's editablefields module updates the field and changes the field id to something like this:
#edit-field-days-start-time-und-0-value-1
Now the jquery-ui-timepicker is no longer binded to an element that exists, so if the user clicks on a second button in the widget, say the minutes, i get an error:
uncaught exception: Missing instance data for this timepicker
So my question is, how do i forcibly rebind the timepicker to a new ID? or alternatively, how do i block the drupal editablefields module from saving the update and changing the id of the field until the edit is complete?
Figured it out, a bit hacky but it works, maybe someone will find this one day.
// global timeout variable
var t=0;
// global variable to represent current time picker
var timepickerInst='';
function onSelectCallback(){
t=setTimeout("dateUpdateCallback()",50);
}
function onCloseCallback(){
}
function dateUpdateCallback(){
$=jQuery;
if( $('#'+timepickerID).length != 0 ){
t=setTimeout("dateUpdateCallback()",50);
}
else {
setupTimepicker($);
//jQuery(document).find('#'+timepickerID).focus();
}
}
function setupTimepicker($){
timepickerID = $('.form-item-field-days-start-time-und-0-value .text-full.form-text').attr('id');
$('.form-item-field-days-start-time-und-0-value .text-full.form-text').timepicker({
// Options
timeSeparator: ':', // The character to use to separate hours and minutes. (default: ':')
showLeadingZero: false, // Define whether or not to show a leading zero for hours < 10.
showMinutesLeadingZero: true, // Define whether or not to show a leading zero for minutes < 10.
showPeriod: true, // Define whether or not to show AM/PM with selected time. (default: false)
showPeriodLabels: true, // Define if the AM/PM labels on the left are displayed. (default: true)
periodSeparator: ' ', // The character to use to separate the time from the time period.
defaultTime: '08:00', // Used as default time when input field is empty or for inline timePicker
// Localization
hourText: 'Hour', // Define the locale text for "Hours"
minuteText: 'Min', // Define the locale text for "Minute"
amPmText: ['AM', 'PM'], // Define the locale text for periods
// Position
myPosition: 'left top', // Corner of the dialog to position, used with the jQuery UI Position utility if present.
atPosition: 'left bottom', // Corner of the input to position
onSelect: onSelectCallback,
onClose: onCloseCallback,
// custom hours and minutes
hours: {
starts: 02, // First displayed hour
ends: 21 // Last displayed hour
},
minutes: {
starts: 0, // First displayed minute
ends: 45, // Last displayed minute
interval: 15 // Interval of displayed minutes
},
rows: 4, // Number of rows for the input tables, minimum 2, makes more sense if you use multiple of 2
showHours: true, // Define if the hours section is displayed or not. Set to false to get a minute only dialog
showMinutes: true, // Define if the minutes section is displayed or not. Set to false to get an hour only dialog
// buttons
showCloseButton: true, // shows an OK button to confirm the edit
closeButtonText: 'Done', // Text for the confirmation button (ok button)
showNowButton: false, // Shows the 'now' button
nowButtonText: 'Now', // Text for the now button
showDeselectButton: false, // Shows the deselect time button
deselectButtonText: 'Deselect' // Text for the deselect button
});
}
jQuery(document).ready( function($) {
setupTimepicker($);
});
I need a specific behavior of jQuery UI Datepicker:
By clicking on 'Prev/Next Month' current day of month must be automatically set in the previous/next month.
e.g.: default date was set to 8/25/2011, after clicking 'Next month' (or selecting September in dropdown), 9/25/2011 must be automatically selected (but not populated to input and datepicker itself must not disappear, so user can change this default day of month).
Thanks for advice.
You can make use of the beforeShowDay event.
var defaultDay = 15;
$('#datepicker').datepicker({
beforeShowDay: function(date) {
if (date.getDate() == defaultDay)
return [1, 'ui-state-highlight ui-state-active']; // can replace with a customised class
return [1, ''];
},
defaultDate: '07/' + defaultDay + '/2011'
});
You can assign a customised class yourself and style it to your heart's content.
Example: http://jsfiddle.net/william/nNmg2/
Note: you may need to take care of double-digit padding, if defaultDay is 1 to 9.