Forum


04:26

17/12/2009

First I have to say that jqGrid is a really excellent component and has helped accelerate the project I'm working on!
I've been struggling with adding form based editing into my grid.
I'm using the latest jqGrid 3.6 and I'm using Grails 1.1 on the server side.
I've taken the Form Enhancement (3.5) demo as a template and have written a grid that populates
via the 'url' correctly but when calling editUrl for either 'Add Record' or Edit returns to the
edit form dialog the following type of error:
“error Status: '/WEB-INF/grails-app/views/configuration/myEdit.jsp'. Error code: 404″
The correct grails method is called and I can see it is sent all the correct params, but
a 404 is seen on the form.
Does the server-side method need to return anything special that I'm missing?
Any help would be appreciated.
14:10

17/12/2009

My mistake. As a quick test I was using the same grails method in both url and editurl. Doh.
The set of params given to the url server method are clearly different to the params given to the server method
for editurl.
Changing the server edit method to handle the following type of params:
[oper:edit, field1:test data field1, action:handleEdit, field2:test data field2,
controller:configuration, id:10]
as opposed to the params that the populate method would handle:
[action:handlePopulate, sidx:type, rows:10, _search:false, page:1,
controller:configuration, nd:1261050351812, sord:desc]
Here are the grails methods that I've got working, ported from the demos:
def handlePopulate = { println "populateSoftComponents:"+params if (params?.rows){ // get how many rows we want to have into the grid // - rowNum parameter in the grid def limit = params.rows?.toInteger() // Get the requested page. By default grid sets this to 1. def pageNum = params.page?.toInteger() // get index row - i.e. user click to sort. At first time sort name parameter - // after that the index from colModel def sidx = params.sidx?.toLowerCase() // sorting order - at first time sort order def sord = params.sord // if we not pass at first time index use the first column for the index or what you want if(!sidx) sidx =1; // calculate the number of rows for the query. We need this for paging the result def count = MyData.count();
def total_pages = 0; // calculate the total pages for the query if( count > 0 && limit > 0) total_pages = (Math.ceil(count/limit)).toInteger(); // if for some reasons the requested page is greater than the total // set the requested page to total page if (pageNum > total_pages) pageNum=total_pages; // calculate the starting position of the rows def start = limit*pageNum - limit; // if for some reasons start position is negative set it to 0 // typical case is that the user type 0 for the requested page if(start <0) start = 0; // the actual query for the grid data def data= MyData.list(max:limit, offset:start, sort:sidx, order:sord); println "made it here" // render page of logs as XML markup to the response // that jqGrid accepts render(contentType:"text/xml") { rows { page(pageNum) total(total_pages) records(count) for(d in data) { row(id:d.id){ cell(d.field1) cell(s.field2) } }//for }//rows }//render }//if params?.rows } def handleEdit = { //Stub : edit the specific record // renders text for a specified content-type/encoding render(text:"some xml",contentType:"text/xml",encoding:"UTF-8") }
Most Users Ever Online: 715
Currently Online:
56 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