Forum


I am using the search option to set common values in the grid: when you select a person and a period, , you can add entries to the grid for that person and period. When Add is called, I check the values of the search options (I use a custom search so they always show above the grid) to se the default values in the edit form. ThIs works, the first time.
It does not work after the first time.
My code appears below. The part I was counting on to do the work is just this much (from onInitializeForm in the addparameters):
$("#item_fk",formid).val(searchOptions.item_fk);
$("#item_fk").attr('disabled',true);
$("#calendar_period",formid).val(searchOptions.calendar_period);
$("#calendar_period").attr('disabled',true);
The first time I click Add, this seems to work, but after that it does not; it seems that it works only immediately after the search has been executed. Does this make sense?
Is there another way to get the values in the search fields? Something like $("#sg_item_fk"). I haven't been able to figure how to make this work.
Any help would be greatly appreciated.
Reg
$("#postingtime").jqGrid( {
url: 'wc.dll?PSProcess~AjaxGet~&Data=postingtime&Key=2&sk=33R0TBNY115112&sh=82',
datatype: 'local',
colNames: ['Postings for','In','Week','Project','Project','Title','ProjectID','Structure','Client','ClientID','Location','Activity','Duration','Invoice','Description','Batch'],
colModel: [{name:'item_fk', search:true, editable:true, hidden:true, editrules:{edithidden:true, searchhidden:true}, edittype:'select', editoptions:{value:'0:Please Select;1:Brehaut, Reg J.'}, width:5 },
{name:'calendar_period', search:true, editable:true, hidden:true, editrules:{edithidden:true, searchhidden:true}, edittype:'select', editoptions:{value:201001:January 2010;201002:February 2010;201003:March 2010;201004:April 2010;201005:May 2010;201006:June 2010;201007:July 2010;201008:August 2010;201009:September 2010;201010:October 2010;201011:November 2010;201012:December 2010;201101:January 2011'}, width:5 },
{name:'week', align:'center', search:false, sortable:true, editable: true, edittype:'select', editoptions:{value:' 0:;2:2;4:4'}, width:60 },
{name:'project', hidden:true, editable:true, editrules:{edithidden:true}, width:250,
editoptions:{
size: 59,
maxlength: 25,
dataInit : function(elem) {
setTimeout(function() {
$(elem).autocomplete({
source: "wc.dll?PSProcess~AutoCompleteProject~&sk=33R0TBNY115112&sh=82" ,
minLength: 1,
select: function(event, ui) {
$("#project").val(ui.item.label);
$("#projectnumber").val(ui.item.project);
$("#shorttitle").val(ui.item.shorttitle);
$("#project_fk").val(ui.item.id);
$("#structure_fk").val(ui.item.structure_fk);
$("#client").val(ui.item.client);
$("#client_fk").val(ui.item.client_fk);
if ($("#structure_fk").val == "97") {
$("#tr_client").show();
};
},
change: function(event,ui) {
if(!ui.item) {
$("#project").val(' ');
$("#projectnumber").val(' ');
$("#shorttitle").val(' ');
$("#project_fk").val(' ');
$("#structure_fk").val(' ');
$("#client").val(' ');
$("#client_fk").val(' ');
$("#tr_client").hide();
}
}
})
},100)
}
}
},
{name:'projectnumber', index:'project', search:false, editable:true, editoptions:{size:'5', maxlength:'8'}, width:65 },
{name:'shorttitle', index:'project', search:false, editable:true, editoptions:{size:'50', maxlength:'25'}, width:150 },
{name:'project_fk', hidden:true, editable:true, width:30 },
{name:'structure_fk', hidden:true, editable:true, width:30 },
{name:'client', index:'client', search:false, editable:true, edittype:'text', editrules:{required:true}, width:200,
editoptions:{
dataInit : function(elem) {
setTimeout(function() {
$(elem).autocomplete({
source: "wc.dll?PSProcess~AutoCompleteCV~&t=C&sk=33R0TBNY115112&sh=82" ,
minLength: 3,
select: function(event, ui) {
$("#client_fk").val(ui.item.id);
$("#client").val(ui.item.label);
},
change: function(event,ui) {
if(!ui.item) {
$("#client_fk").val(' ');
$("#client").val(' ');
}
}
})
},100)
}
}
},
{name:'client_fk', hidden:true, editable:true, width:30 },
{name:'location_fk', index:'location', hidden:true, editable:true, edittype:'select', editrules:{edithidden:true}, editoptions:{value:'87:Office;88:On Site;89:Out of Calgary;91:Offshore;90:International;94:Travelling'}, width:120 },
{name:'activity_fk', hidden:true, index:'activity', editable:true, edittype:'select', editrules:{edithidden:true}, editoptions:{value:'118:Administration;115:Annual Maintenance Support;114:Bug Fixing;112:Installation Support;92:Project Work;94:Training;119:Travel TIme'}, width:120 },
{name:'qty', align:'right', search:false, editable:true, editoptions:{size:'5', maxlength:'5'}, width:80 },
{name:'invoice', hidden:true, editable:true, editrules:{edithidden:true}, editoptions:{size:'5', maxlength:'5'}, width:3 },
{name:'comment', hidden:true, sortable:false, editable:true, editrules:{ edithidden:true }, edittype:'textarea', editoptions:{rows:5,cols:60}, width:100 },
{name:'batch_fk', align:'right', editable:false, search:false, width:60 } ],
height: 'auto',
altRows: true,
altclass: 'ui-priority-secondary',
gridview: true,
pager: '#postingtimePager',
pagerpos: 'center',
recordpos: 'right',
rowList:[10,25,50,100,999],
page: 1,
rowNum:25,
recordtext:'Entries',
loadui: 'block',
sortname: 'project',
sortorder: 'asc',
viewsortcols: [true,'horizontal',true],
hidegrid: false,
caption: 'Posting Time',
editurl:'wc.dll?PSProcess~AjaxPut~&Data=postingtime&sk=33R0TBNY115112&sh=82',
loadError: function(xhr,st,err) {
$("#postingtimeMessage").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
},
loadComplete: function() {
},
gridComplete: function() {
UpdateTotals();
}
});
var sg = $("#srcpostingtime").filterGrid("postingtime",{
gridModel:true,
gridNames:true,
formtype:"vertical",
enableSearch: true,
enableClear: false,
searchButton: "Set",
clearButton: "Default",
autosearch: false
})[0];
$("#postingtime").setGridParam({datatype:'xml'});
sg.triggerSearch()
$("#postingtime").navGrid('#postingtimePager',{
refresh:true,add:true,addtext:'Add',edit:true, edittext:'Edit',del:true, deltext:'Delete',search:false
},
{
width: 500,
recreateform:true,
onInitializeForm : function (formid){// GetFindProjectButton(this)
// hide columns not used in this installation
$("#tr_client",formid).hide();
$("#tr_projectnumber",formid).hide();
$("#tr_shorttitle",formid).hide();
$("#pData,#nData",formid).hide();
$("#item_fk").attr('disabled',true);
$("#calendar_period").attr('disabled',true);
if($("#invoice").val() == 0) {
$("#week").attr('disabled',false);
$("#project").attr('disabled',false);
$("#activity_fk").attr('disabled',false);
$("#location_fk").attr('disabled',false);
$("#qty").attr('disabled',false);
$("#comment").attr('disabled',false);
$("#tr_invoice",formid).hide();
} else {
alert('This item has been Invoiced; it can no longer be edited');
$("#week").attr('disabled',true);
$("#project").attr('disabled',true);
$("#activity_fk").attr('disabled',true);
$("#location_fk").attr('disabled',true);
$("#qty").attr('disabled',true);
$("#comment").attr('disabled',true);
$("#invoice").attr('disabled',true);
$("#tr_invoice",formid).show();
};
}
}, // edit
{
width: 500,
recreateform:true,
beforeInitData : function (formid) {
var searchOptions = $("#postingtime").getGridParam("postData");
if(searchOptions.item_fk == 0) {
alert('Sorry, cannot add until posting criteria entered');
return false ;
}
},
onInitializeForm : function (formid){
// GetFindProjectButton(this)
// hide columns not used in this installation
$("#tr_client",formid).hide();
$("#tr_projectnumber",formid).hide();
$("#tr_shorttitle",formid).hide();
var searchOptions = $("#postingtime").getGridParam("postData");
$("#item_fk",formid).val(searchOptions.item_fk);
$("#item_fk").attr('disabled',true);
$("#calendar_period",formid).val(searchOptions.calendar_period);
$("#calendar_period").attr('disabled',true);
$("#location_fk",formid).val("87");
$("#activity_fk",formid).val("92");
$("#tr_invoice",formid).hide();
$("#week",formid).focus();
}
}, // add
{} // delete
);
//-->
Most Users Ever Online: 715
Currently Online:
62 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66