-
Notifications
You must be signed in to change notification settings - Fork 142
Added option for HTML5 datalist input #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,13 +135,13 @@ function getInputHtml(currentColumnIndex, settings, oldValue) { | |
input = {"focus":true,"html":null}; | ||
|
||
if(settings.inputTypes){ | ||
$.each(settings.inputTypes, function (index, setting) { | ||
if (setting.column == currentColumnIndex) { | ||
inputSetting = setting; | ||
inputType = inputSetting.type.toLowerCase(); | ||
} | ||
}); | ||
} | ||
$.each(settings.inputTypes, function (index, setting) { | ||
if (setting.column == currentColumnIndex) { | ||
inputSetting = setting; | ||
inputType = inputSetting.type.toLowerCase(); | ||
} | ||
}); | ||
} | ||
|
||
if (settings.inputCss) { inputCss = settings.inputCss; } | ||
if (settings.wrapperHtml) { | ||
|
@@ -183,30 +183,70 @@ function getInputHtml(currentColumnIndex, settings, oldValue) { | |
input.html = input.html + "</select> <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this);'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
input.focus = false; | ||
break; | ||
case "datalist": | ||
if (!startWrapperHtml) { | ||
startWrapperHtml = '<div>' | ||
endWrapperHtml = '</div>' | ||
} | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' list='datalist-" + currentColumnIndex + "' class='" + inputCss + "' value='" + oldValue + "' onfocusout='$(this).updateEditableCell(this);'>"; | ||
input.html = input.html + "</input>"; | ||
input.html = input.html + "<datalist id='datalist-" + currentColumnIndex + "'>"; | ||
|
||
$.each(inputSetting.options, function (index, option) { | ||
if (oldValue == option.value) { | ||
input.html = input.html + "<option value='" + option.value + "'>" | ||
} else { | ||
input.html = input.html + "<option value='" + option.value + "' >" | ||
} | ||
}); | ||
input.html = input.html + "</datalist>"; | ||
input.html = input.html + endWrapperHtml; | ||
input.focus = true; | ||
break; | ||
case "datalist-confirm": // DataList w/ confirm | ||
if (!startWrapperHtml) { | ||
startWrapperHtml = '<div>' | ||
endWrapperHtml = '</div>' | ||
} | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' list='datalist-" + currentColumnIndex + "' class='" + inputCss + "' value='" + oldValue + "'>"; | ||
input.html = input.html + "</input>"; | ||
input.html = input.html + "<datalist id='datalist-" + currentColumnIndex + "'>"; | ||
|
||
$.each(inputSetting.options, function (index, option) { | ||
if (oldValue == option.value) { | ||
input.html = input.html + "<option value='" + option.value + "' selected>" | ||
} else { | ||
input.html = input.html + "<option value='" + option.value + "' >" | ||
} | ||
}); | ||
input.html = input.html + "</datalist>"; | ||
input.html = input.html + " <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this);'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>"+ endWrapperHtml; | ||
input.focus = true; | ||
break; | ||
case "datepicker": //Both datepicker options work best when confirming the values | ||
case "datepicker-confirm": | ||
// Makesure jQuery UI is loaded on the page | ||
if (typeof jQuery.ui == 'undefined') { | ||
alert("jQuery UI is required for the DatePicker control but it is not loaded on the page!"); | ||
break; | ||
} | ||
jQuery(".datepick").datepicker("destroy"); | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' type='text' name='date' class='datepick " + inputCss + "' value='" + oldValue + "'></input> <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this)'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
setTimeout(function () { //Set timeout to allow the script to write the input.html before triggering the datepicker | ||
var icon = "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif"; | ||
jQuery(".datepick").datepicker("destroy"); | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' type='text' name='date' class='datepick " + inputCss + "' value='" + oldValue + "'></input> <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this)'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
setTimeout(function () { //Set timeout to allow the script to write the input.html before triggering the datepicker | ||
var icon = "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif"; | ||
// Allow the user to provide icon | ||
if (typeof inputSetting.options !== 'undefined' && typeof inputSetting.options.icon !== 'undefined') { | ||
icon = inputSetting.options.icon; | ||
} | ||
var self = jQuery('.datepick').datepicker( | ||
if (typeof inputSetting.options !== 'undefined' && typeof inputSetting.options.icon !== 'undefined') { | ||
icon = inputSetting.options.icon; | ||
} | ||
var self = jQuery('.datepick').datepicker( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just replaced tab with space. |
||
{ | ||
showOn: "button", | ||
buttonImage: icon, | ||
buttonImageOnly: true, | ||
buttonText: "Select date" | ||
}); | ||
},100); | ||
break; | ||
},100); | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just replaced tab with space. |
||
case "text-confirm": // text input w/ confirm | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' class='" + inputCss + "' value='"+oldValue+"'" + (listenToKeys ? " onkeyup='if(event.keyCode==13) {$(this).updateEditableCell(this);} else if (event.keyCode===27) {$(this).cancelEditableCell(this);}'" : "") + "></input> <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this)'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
break; | ||
|
@@ -219,9 +259,9 @@ function getInputHtml(currentColumnIndex, settings, oldValue) { | |
case "textarea-confirm": | ||
input.html = startWrapperHtml + "<textarea id='ejbeatycelledit' class='" + inputCss + "'>"+oldValue+"</textarea><a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this)'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
break; | ||
case "number-confirm" : | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' type='number' class='" + inputCss + "' value='"+oldValue+"'" + (listenToKeys ? " onkeyup='if(event.keyCode==13) {$(this).updateEditableCell(this);} else if (event.keyCode===27) {$(this).cancelEditableCell(this);}'" : "") + "></input> <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this)'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
break; | ||
case "number-confirm" : | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' type='number' class='" + inputCss + "' value='"+oldValue+"'" + (listenToKeys ? " onkeyup='if(event.keyCode==13) {$(this).updateEditableCell(this);} else if (event.keyCode===27) {$(this).cancelEditableCell(this);}'" : "") + "></input> <a href='javascript:void(0);' class='" + confirmCss + "' onclick='$(this).updateEditableCell(this)'>Confirm</a> <a href='javascript:void(0);' class='" + cancelCss + "' onclick='$(this).cancelEditableCell(this)'>Cancel</a>" + endWrapperHtml; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added indentation |
||
break; | ||
default: // text input | ||
input.html = startWrapperHtml + "<input id='ejbeatycelledit' class='" + inputCss + "' onfocusout='$(this).updateEditableCell(this)' value='" + oldValue + "'></input>" + endWrapperHtml; | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just replaced tabs with space.