Forum



20:59

23/12/2010

I have a site I am building which has variable parameters for the jqGrid to use. In IE8 it handles the click events correctly, but in Firefox, the Add button doesn't fire, the Delete button doesn't file and neither does it sort. Also in both browsers the "Alert" caption shows continuously even though nothing has been clicked.
I have changed none of the defaults. Here is my code:
*********************************************************************
$(document).ready(function() {
var grid = jQuery("#" + tblName).jqGrid({
url: svcName + "/getRows",
datatype: 'json',
mtype: 'POST',
loadonce: true,
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
serializeGridData: function(postData) {
return JSON.stringify(postData);
},
jsonReader: {
root: function(obj) { return obj.d.rows; },
page: function(obj) { return obj.d.page; },
total: function(obj) { return obj.d.total; },
records: function(obj) { return obj.d.records; }
}, //jsonReader
columns: cols,
colModel: model,
onSelectRow: function(id) {
if (id && id !== lastSel) {
if (lastSel == -1) test();
if (canEdit()) {
// cancel editing of the previous selected row if it was in editing state.
// jqGrid hold intern savedRow array inside of jqGrid object,
// so it is safe to call restoreRow method with any id parameter
// if jqGrid not in editing state
grid.jqGrid('saveRow', lastSel);
} //if canEdit()
lastSel = id;
} //if id!=lastSel
lastSel = id;
},
ondblClickRow: function(id, ri, ci) {
if (canEdit()) {
// edit the row and save it on press "enter" key
grid.jqGrid('editRow', id, true);
lastSel = id;
}
},
editurl: svcName + '/updateRow',
pager: pagerID,
rowNum: 5000, //MAX rows to display?
gridview: true,
hidegrid: false,
shrinkToFit: true,
scroll: true,
altRows: true,
altclass: 'odd' + tblName,
toolbar: [true, 'both'],
footerrow: false,
height: gridHeight,
caption: caption
}).jqGrid('navGrid', '#' + pagerID, { add: false, edit: false, view: false, del: false, refresh: false, search: false })
.navButtonAdd('#' + pagerID,
{
caption: "Add ",
buttonicon: "ui-icon-add",
onClickButton: function() {
var itemArray = "{";
for (var i = 0; i < cols.length; i++) {
if (cols[i].toLowerCase() == "id") {
itemArray += cols[i] + ":'-1',";
}
else
itemArray += cols[i] + ":'',";
}
//remove last comma from itemArray
itemArray = itemArray.substring(0, itemArray.length - 1);
var total = grid.getGridParam('records');
grid.addRowData(-1, itemArray, 'last'); // add a new row with empty data
lastSel = -1;
grid.jqGrid('editRow', -1, true);
//jQuery("#grid_id").jqGrid('editRow',rowid, keys, oneditfunc, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc);
},
position: "last",
cursor: "pointer"
})
.navButtonAdd('#' + pagerID,
{
caption: " Del",
buttonicon: "ui-icon-del",
onClickButton: function(id) {
alert("Deleting Row: " + lastSel)
//put ajax call in here to delete the row - LastSel gives the row keyname
},
position: "last",
cursor: "pointer"
});
});//document.ready
*********************************************************************
The Add button works, but I get and error 500 from the webservice when I try to save the insert. Because the buttons do not work in FireFox I can't use Firebug to figure out what is being sent. As you can tell, I am a complete newbie to both jQuery and jqGrid, so thanks for the help on this.
Geoff
14:32

Moderators
30/10/2007

Hello,
Please check your code again. Also check if you have loaded all the needed JavaScript and CSS files.
In order to isolate the problem begin with very simple example.
Also I see one time you use
.jqGrid('navGrid', '#' + pagerID, { add: false, edit: false, view: false, del: false, refresh: false, search: false })
but after this
jQuery("#" + tblName).navButtonAdd('….
PLEASE TURN OFF THE $.jgrid.no_legacy_api option like this
$.jgrid.no_legacy_api = false
or use
jQuery("#" + tblName).jqGrid('navButtonAdd', ….
Kind Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
16:32

23/12/2010

I have now modified the code so that it is only using the new API. I have also eliminated all extra tags to simplify it as you suggested. I put breakpoints on the system to view the value of data before it is sent to the webservice. The service is expecting 3 strings: test1, test2 and test3. The data I have experimented with to be {test1:"", test2:"", test3:""} or {"test1":"","test2":"","test3":""} as well as '{"test1":"","test2":"","test3":""}'. Each of these variations gives me a return value of parameter test1 expected when I try to insert the data.
Is this a problem with how I am using jqGrid or more likely to be my service?
Thanks for the help.
Geoff
Most Users Ever Online: 715
Currently Online:
63 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