Hi Tony,
I am trying to integrate the alphanumeric plugin into jqgrid. This plugin allows you to limit input in textfields and areas to specific characters. The plugin works by adding a class to an input field. I tried this on a grid but notting happens. The class is added normally, but it does not respond to the plugin. Other “normal” fields on the layout perform without a problem. Here is my code:
var lastsel;
if (window.innerWidth) //if browser supports window.innerWidth
var fullwidth= window.innerWidth-60
else if (document.all) //else if browser supports document.all (IE 4+)
var fullwidth=document.body.clientWidth-18;
recno=$("#recid").val()
jQuery("#rowpain").jqGrid({
url:'../widg_pain/portaldata.php?ID='+recno,
datatype: "json",
colNames:,
colModel:[
{name:'tijd',index:'tijd', width:15, max:5,editable:true,sortable:false,edittype:"text", editoptions : {size:2, maxlength: 5}},
{name:'klok',index:'klok', width:15, editable:true,sortable:false, edittype:"text", editoptions : {size:5, maxlength: 5, class:"klok"}},
{name:'rem',index:'rem', width:20, editable:true,sortable:false,edittype:"select",editoptions: {value:":;Ja:Ja;Nee:Nee"}},
{name:'atro',index:'atro', width:20,editable:true,sortable:false,edittype:"select",editoptions: {value:":;Ja:Ja;Nee:Nee"}},
{name:'naxo',index:'naxo', width:20,editable:true,sortable:false,edittype:"select",editoptions: {value:":;Ja:Ja;Nee:Nee"}},
{name:'opu',index:'opu', width:20, editable:true,sortable:false ,edittype:"select",editoptions: {value:":;Ja:Ja;Nee:Nee"}},
{name:'bld',index:'bld', width:20, editable:true,sortable:false,edittype:"text", editoptions : {size:3, maxlength: 3}},
{name:'blb',index:'blb', width:20, editable:true,sortable:false,edittype:"text", editoptions : {size:3, maxlength: 3}},
{name:'sat',index:'sat', width:20, editable:true, sortable:false,edittype:"text", editoptions : {size:3, maxlength: 3}},
{name:'vas',index:'vas', width:20, editable:true, sortable:false,edittype:"text", editoptions : {size:2, maxlength: 2}},
{name:'sed',index:'sed', width:20, editable:true, sortable:false,edittype:"text", editoptions : {size:1, maxlength: 1}},
{name:'oxy',index:'oxy', width:20, editable:true, sortable:false,edittype:"text", editoptions : {size:2, maxlength: 2}}
],
rowNum:10,
imgpath: '../images/jqgrid',
pager: jQuery('#prowpain'),
sortname: 'id',
loadonce: true,
viewrecords: true,
width: fullwidth,
rowheight: 17,
recordtext:"Embryo's",
loadtext:"Laden...",
onSelectRow: function(id){
if(id && id!==lastsel){
jQuery('#rowpain').saveRow(lastsel,checksave);
jQuery('#rowpain').editRow(id,true);
lastsel=id;
}
},
editurl: "editpaingrid.php"
});
function checksave(result) {
if (result=="Saved" || result=="")
{
return true;
}
else
{
alert("Update error!");
return false;
}
};
Note the editoptions in the second column: {name:’klok’,index:’klok’, width:15, editable:true,sortable:false, edittype:”text”, editoptions : {size:5, maxlength: 5, class:”klok”}},
This will add the class “klok” to the input field. After inclusion of the alphanumeric plugin all I should need to do is add a line like:
$('.klok').numeric({allow:":"});
This works like a charm for any field ouside the grid. Why not inside it?
Thanks.
W.
P.S. my full code of the grid + html is below:
index.php:
0 ||$punCheckSetDBData('opu', 'pain_monitor');
$opuMon->SetDataKey ('id','','.'); //SQL specific
$opuMon->SetDBUserPass ('root', 'pass');
$opuMon->AddDBParam('date', $pundate);
$opuMon->AddDBParam('patient', $id);
$opuData = $opuMon->FMFind();
$currentKey = key($opuData);
if ($opuData==0) {
$opuMon->AddDBParam('patient', $id);
$opuMon->AddDBParam('patient_name', $pat);
$opuMon->AddDBParam('date', $pundate);
$opuMon->AddDBParam('monBy', $user);
$opuData = $opuMon->FMNew(true);
$opuMon = new FX('127.0.0.1', '3306', 'MySQL');
$opuMon->SetDBData('opu', 'pain_monitor');
$opuMon->SetDataKey ('id','','.'); //SQL specific
$opuMon->SetDBUserPass ('root', 'pass');
$opuMon->AddDBParam('date', $pundate);
$opuMon->AddDBParam('patient', $id);
$opuData = $opuMon->FMFind();
$currentKey = key($opuData);
$count=$opuData;
}
?>
.digits.error {
border: 1px solid #c24949;
background: #ffbcbc;
}
.digits.success {
border: 1px solid blue;
background: blue;
size: 18px;
}
$(document).ready(function(){
var validator = $("#detailform").validate({
rules: {
weight: {
digits: true,
min: 35,
max: 300
}
},
messages: {
weight: "Gewicht in hele kilo's graag "
},
submitHandler: function() {
process('./widg_pain/updatepainmon.php');
$("input[@type='submit']").removeClass('changed');
},
success: function(label) {
label.addClass("success").text("")
},
onkeyup: false
});
$("input[@type='text']").change( function() {
$("input[@type='submit']").addClass('changed');
});
$("textarea").change( function() {
$("input[@type='submit']").addClass('changed');
});
$('.klok').numeric({allow:":"});
$('.gewicht').numeric({allow:"."});
$("#embresult").hide();
});
Bijlage 4: OPU Verslag Bewaking
pte:
gewicht pte: kg
Aanvangdosis Remifentanil: µg
Herhalings dosis Remifentanil: µg (protocol)
Opmerking
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top