Forum


04:29

21/07/2012

Hello,
I have a jqGrid set up with cell editing and everything is working great! I am using custom editrules that perform ajax calls to do custom validation. To perform this validation, I am using the following command to get id of the row that is being edited:
The problem I am having is that when I edit a cell and then click on another row (thus causing the cell to save), the validation gets the rowId of the newly clicked on cell because the editrules function is firing after the selected row changes. Is there another way to get rowId that avoids this problem?
Below is an example of my code:
jQuery("#capacity_list").jqGrid({
...
colModel: [
{name:'currentCapacity', width:50, editable:true, editrules:{number:true, "custom":true, "custom_func":validateCapExpand}},
...
function validateCapExpand(data, value) {
var result = [true, ''];
var rowId = jQuery("#capacity_list").getGridParam('selrow');
if(rowId) {
jQuery.ajax({
async: false,
url: 'asset/validateCapExpand',
data: { currentCapacity: data, assetId: ${assetInstance.id}, rowId: rowId },
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function(data) {
if(data.retVal) {
result = [true, '']
} else {
result= [false, ' is greater than max expandable'];
}
},
error: function () { alert('Error trying to validate'); }
});
}
return result;
}
Thanks for any help!
- Nisrak
Most Users Ever Online: 715
Currently Online:
38 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