Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






Custom validation with "actions" formatter edits

UserPost

02:02
25/07/2012


nisrak

Member

posts 4

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:


class VirtualResource {

    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:


Field error in object 'edu.hawaii.sitar.inf.VirtualResource' on field 'resourceCapacity': rejected…

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:


$(document).ready(function() {

    $("#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'
        })
    });

01:32
02/08/2012


nisrak

Member

posts 4

Anyone have any idea how to do this please?

- Nisrak


About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

157


Currently Online:

26 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 9596

Posts: 28792

Membership:

There are 10196 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1157

markw65 – 179

kobruleht – 144

phicarre – 126

YamilBracho – 124

Renso – 118

Administrators: admin (56 Posts)

Moderators: tony (7010 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information