Forum
18:13
07/04/2009
I have a grid on which I need to populate the edit form with data fetched from the server for one particular element. The grid constructor is:
jQuery("#dataList").jqGrid({
url:'/input/getcamp?format=json',
datatype: "json",
colNames:['Id','Name','Brand','Property','Attributes'],
colModel:[
{name:'id',index:'id', width:0,editable:false,hidden:true},
{name:'cName',index:'cName',editable:true,sortable:true,editrules:{required:true}},
{name:'bName',index:'bName',sortable:true,editable:true,edittype:"select",editoptions:{value:selBrand}},
{name:'pName',index:'pName',sortable:true,editable:true,edittype:"select",editoptions:{value:selProperty}},
{name:'attribs',index:'attribs',hidden:true,editable:true,edittype:'custom',editoptions:{custom_element:_setCheckGroup,custom_value:_getCheckGroup},editrules:{edithidden:true}}
],
rowNum:10,
rowList:[10,20,30,40,50],
pager: '#dataListPager',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Campaign Maintenance",
autowidth:true,
height:300,
scroll:true,
loadComplete:function(){gridOnLoad();},
onSelectRow:function(){showEditRowButton();}
});
The custom functions are:
//set up the attributes edit element in campaign edit
function _setCheckGroup(value, options) {
var cId = $("#dataList").jqGrid('getGridParam','selrow');
var t = $("#dataList").jqGrid();
var xhtml = '';
var ele = document.createElement('rbAttribs');
$.ajax({url:'/input/getattrib?format=json&cId=' + cId,
success:function(response){
if(response.success) {
for (var x in response.data.allAttribs) {
xhtml += '<input type="checkbox" name="attribs" value="' + x + '"';
if (response.data.thisAttribs[x]) {
xhtml += ' checked';
}
xhtml += ' />' + response.data.allAttribs[x]
}
$(ele).html(xhtml);
} else {
simplePopupMessage({title:"Oops!",message:response.msg,class:'negative'});
return false;
}
},
cache:false,
async:false,
dataType:'json'
});
return ele;
}//return value of edited attributes element from campaign edit
function _getCheckGroup(ele) {
var ret = '';
$(ele + ':checked').each(function(){
ret += $(this).val() + '|';
});
return ret.replace(/\|$/,'');
}
recreateForm is set true in both the edit and add options for the forms
Now this all works fine the first time I edit a row, but for the second and subsequent edits, the _setCheckGroup() function is never called and therefore the contents of the check boxes is not updated from the server. How can I get the grid/form to call _setCheckGroup() every time I edit a row?
Most Users Ever Online: 715
Currently Online:
43 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