Forum



18:46

23/07/2009

Hi,
I'm using version 3.6.4 of jqgrid and having a problem with the SetRowData method. I'm using my own forms (Jquery UI Modal forms). After some debugging I've discovered the problem is because of a date column I have in my grid. If I remove this column the SetRowData method works fine.
Here is the column definition:
{ datefmt:'dd/mm/YYYY', formatter: 'dateFormatter', searchoptions: { dataInit: datePick, searchhidden: true }, name: 'DateAcquired', search: true, sortable: true, hidden: false, index: 'DateAcquired', width: 70, align: 'left', stype: "date" }
This is my custom dateFormatter:
$.fn.fmatter.dateFormatter = function(cellvalue, options, rowObject) {
if (cellvalue == null) return '';
if (cellvalue.indexOf("Date") == -1) return;
// Date arrives from server in the following format /Date(1146006000000)/
// So I remove the forward slashes.
var datePart = cellvalue.toString().replace("/", "");
datePart = datePart.replace("/", "");
var dateValue = 'new ' + datePart + '.toLocaleDateString()';
return eval(dateValue);
}
In the grid column, the date appears as '26 March 2010' for example. It appears correctly in the form when using GridToForm.
The SetRowData method fails on the line in bold with something like a "$ missing" error (can't remember the exact wording).
setRowData : function(rowid, data, cssp) {
var nm, success=false;
this.each(function(){
var t = this, vl, ind, cp = typeof cssp;;
if(!t.grid) {return false;}
ind = t.rows.namedItem(rowid);
if(!ind) return false;
if( data ) {
$(this.p.colModel).each(function(i){
nm = this.name;
if( data[nm] != undefined) {
vl = t.formatter( rowid, data[nm], i, data, 'edit');
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
$("td:eq("+i+") > span:first",ind).html(vl).attr("title",$.jgrid.stripHtml(vl));
} else {
$("td:eq("+i+")",ind).html(vl).attr("title",$.jgrid.stripHtml(vl));
}
success = true;
}
});
}
if(cp === 'string') {$(ind).addClass(cssp);} else if(cp === 'object') {$(ind).css(cssp);}
});
return success;
Can you tell me what I'm doing wrong please.
Regards,
Simon
18:33

Moderators
30/10/2007

Hello,
Could you please post what is the exact data passed to the setRowData.
I'm not sure, but the problem apper to be here:
if (cellvalue.indexOf("Date") == -1) return;
should be
if (cellvalue.indexOf("Date") == -1) return "";
Best 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.
Most Users Ever Online: 715
Currently Online:
168 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