Forum



02:02

21/07/2012

Hi,
I am using the JqGrid plugin for Grails (version 3.8.0.1). I have set up a jqGrid working with the predefined "actions" formatter for delete and edit and everything is working great! I am now trying to get some custom validation rules in place and have run into some problems. I defined a method that compares two values and set it as a constraint in the Domain class. Here is a sample of this definition:
def assetService
Asset asset
Float resourceCapacity = 0.0f
static belongsTo = [ asset : Asset ]
static constraints = {
resourceCapacity( validator:{ cap, item ->
item.assetService.checkCapacityAllocation(item.asset, cap, item, "add")
})
}
This constraint works fine with add (which I am doing via a custom button). When I use the inline edit with the actions formatter, however, it accepts the input, displays no errors to the user, and gives the console error:
I have tried using every formatOption I could think of (onError, etc.) but none seem to work! I also tried using custom error notification but I cant figure out how to manipulate the actions formatter (again, formatOptions don't seem to be working). If this is an issue with the version I am using (3.8.0.1), is there a way to get a newer version working with Grails?
Any help would be greatly appreciated! Below is some of the code I am using for the jqgrid:
$("#btnAddVResource").click(function(){
$("#vResource_list").jqGrid("editGridRow","new",
{addCaption:'Create New Virtual Resource',
width:500, height:200,
closeAfterAdd: true,
params:{asset:${assetInstance.id}},
savekey:[true,13]});
});
jQuery("#vResource_list").jqGrid({
height:'240',
width:'1200',
caption:'Capacity List',
showPager:'true',
url:listVResourceUrl,
editurl:'asset/editVResource?assetId=${assetInstance.id}',
datatype: "json",
colNames:['', 'Resource Type', 'Amount Allocated', 'Unit Type', 'id'],
colModel:[
{name:'actions', index:'actions', editable:false, required:false, sortable:false, width:"20",
formatter: 'actions', hidden:!editOption,
formatoptions: {},
{name:'resourceType', width:35, editable:true, edittype:'select', editoptions: {value:
{'CPU':'CPU', 'Memory':'Memory', 'Disk':'Disk'}}},
{name:'resourceCapacity', width:50, editable:true, editrules: {number:true}},
{name:'unitType', width:30, editable:true, edittype:'select', editoptions: {value:
{'Threads':'Threads', 'Gigabytes':'Gigabytes', 'Terabtyes':'Terabytes'}}},
{name:'id', hidden:true}
],
rowNum:10,
rowList:[1,2,3,4,5,6,7,8,9,10],
pager: jQuery('#capacity_list_pager'),
viewrecords: true,
gridview: true,
cellsubmit: 'remote'
})
});
Most Users Ever Online: 715
Currently Online:
23 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