Skip to content

Commit

Permalink
Fixed issue #6067 (partial fix) - jqGrid behaviours for editing attri…
Browse files Browse the repository at this point in the history
…butes fixed - dropdown appears when dropdown should, dropdown doesn't appear when it shouldn't!
  • Loading branch information
jcleeland committed Jul 29, 2012
1 parent 67c9baf commit 27ebd20
Showing 1 changed file with 54 additions and 42 deletions.
96 changes: 54 additions & 42 deletions scripts/admin/displayParticipant.js
Expand Up @@ -209,6 +209,7 @@ $(document).ready(function() {
}
}
});

/* Subgrid that displays user attributes */
jQuery("#"+subgrid_table_id).jqGrid( {
url: getAttribute_json+'/'+row_id,
Expand All @@ -219,15 +220,18 @@ $(document).ready(function() {
recordtext:'',
pgtext:'',
caption: attributesHeadingTxt,
editable:true,
editable: true,
loadonce : true,
colNames: [actionsColTxt,participantIdColTxt,attributeTypeColTxt,attributeNameColTxt,attributeValueColTxt,attributePosValColTxt],
colModel: [ { name:'act',index:'act',width:55,align:'center',sortable:false,formatter:'actions',formatoptions : { keys:true,onEdit:function(id){ }}},
colModel: [ { name:'act',index:'act',width:55,align:'center',sortable:false,formatter:'actions',formatoptions : { keys:true,onEdit:function(id){
var iRow = $('#' + $.jgrid.jqID(id))[0].rowIndex;
editModifier(id,iRow, method='edit');
}}},
{ name:'participant_id',index:'participant_id', width:150, sorttype:"string",align:"center",editable:true,hidden:true},
{ name:'atttype',index:'atttype', width:150, sorttype:"string",align:"center",editable:true,hidden:true},
{ name:'atttype',index:'atttype', width:150, sorttype:"string",align:"center",editable:false,hidden:true},
{ name:'attname',index:'attname', width:150, sorttype:"string",align:"center",editable:false},
{ name:'attvalue',index:'attvalue', width:150, sorttype:"string",align:"center",editable:true},
{ name:'attpvalues',index:'attpvalues', width:150, sorttype:"string",align:"center",editable:true,hidden:true}],
{ name:'attpvalues',index:'attpvalues', width:150, sorttype:"string",align:"center",editable:false,hidden:true}],
rowNum:20,
pager: pager_id,
gridComplete: function () {
Expand All @@ -236,44 +240,7 @@ $(document).ready(function() {
$("#gview_"+subgrid_table_id).css("margin-top", "20px"); //Some spacing after the subgrid
},
ondblClickRow: function(id,subgrid_id) {
var parid = id.split('_');
var participant_id = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'participant_id');
var lsel = parid[0];
var can_edit = $('#displayparticipants').getCell(participant_id,'can_edit');
if(can_edit == 'false') {
var dialog_buttons={};
dialog_buttons[okBtn]=function(){
$( this ).dialog( closeTxt );
};
/* End of building array for button functions */
$('#notauthorised').dialog({
modal: true,
title: accessDeniedTxt,
buttons: dialog_buttons
});
} else {
var att_type = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'atttype');
if(att_type=="DP") { //Date
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ editoptions:{ dataInit:function (elem) {$(elem).datepicker();}}});
}
if(att_type=="DD") { //Dropdown
var att_p_values = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attpvalues');
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ edittype:'select',editoptions:{ value:":Select One;"+att_p_values}});
}
if(att_type=="TB") { //Textbox
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ edittype:'text'});
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ editoptions:''});
}
var attap = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attap');
if(id && id!==lastSel2) { //If there was already another row open for editin save it before editing this one
jQuery("#displayparticipants_"+parid[0]+"_t").saveRow(lastSel2);
//jQuery.fn.fmatter.rowactions('97358ea2-8227-483b-a225-5d13a522402e_50','displayparticipants_97358ea2-8227-483b-a225-5d13a522402e_t','cancel',0);
lastSel2=id;
}
$.fn.fmatter.rowactions(id,'displayparticipants_'+parid[0]+'_t','edit',0);
jQuery("#displayparticipants_"+parid[0]+"_t").jqGrid('editRow',id,true);
jQuery("#displayparticipants_"+parid[0]+"_t").editRow(id,true);
}
editModifier(id, subgrid_id, method='click');
},
height: '100%'
});
Expand Down Expand Up @@ -702,4 +669,49 @@ $(document).ready(function() {
}
});

function editModifier(id, subgrid_id, method) {
var parid = id.split('_');
var participant_id = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'participant_id');
var lsel = parid[0];
var can_edit = $('#displayparticipants').getCell(participant_id,'can_edit');
if(can_edit == 'false') {
var dialog_buttons={};
dialog_buttons[okBtn]=function(){
$( this ).dialog( closeTxt );
};
/* End of building array for button functions */
$('#notauthorised').dialog({
modal: true,
title: accessDeniedTxt,
buttons: dialog_buttons
});
} else {
var att_type = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'atttype');
if(att_type=="DP") { //Date
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ editoptions:{ dataInit:function (elem) {$(elem).datepicker();}}});
}
if(att_type=="DD") { //Dropdown
var att_p_values = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attpvalues');
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ edittype:'select',editoptions:{ value:":Select One;"+att_p_values}});
}
if(att_type=="TB") { //Textbox
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ edittype:'text'});
$("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{ editoptions:''});
}
var attap = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attap');
if(id && id!==lastSel2) { //If there was already another row open for editin save it before editing this one
jQuery("#displayparticipants_"+parid[0]+"_t").saveRow(lastSel2);
//jQuery.fn.fmatter.rowactions('97358ea2-8227-483b-a225-5d13a522402e_50','displayparticipants_97358ea2-8227-483b-a225-5d13a522402e_t','cancel',0);
lastSel2=id;
}
$.fn.fmatter.rowactions(id,'displayparticipants_'+parid[0]+'_t','edit',0);
if(method=='edit') {
jQuery("#displayparticipants_"+parid[0]+"_t").jqGrid('restoreRow',id);
jQuery("#displayparticipants_"+parid[0]+"_t").restoreRow(id);
}
jQuery("#displayparticipants_"+parid[0]+"_t").jqGrid('editRow',id,true);
jQuery("#displayparticipants_"+parid[0]+"_t").editRow(id,true);
}
}

});

0 comments on commit 27ebd20

Please sign in to comment.