Forum


04:56

17/09/2009

Using the next grid:
var lastsel;
Query("#grid0").jqGrid({
url:url_get,
datatype: "xml",
colNames:[jq_cols[0].col_caption,jq_cols[0].col_caption],
colModel:[
{name:'espcode',index:'espcode', width:64, key:true, editable:true, align:"right",editoptions: {size:3, maxlength: 3}},
{name:'espname',index:'espname', width:210,editable:true,editoptions: {size:38, maxlength: 40}}
],
rowNum:jq_numrows,
autowidth : true,
shrinkToFit: false,
scrollOffset: 0,
gridview: true,
pager: jQuery('#pager'),
viewrecords: true,
onSelectRow: function(id){
if(id && id!==lastsel){
jQuery('#grid0').restoreRow(lastsel);
jQuery('#grid0').editRow(id,true);
lastsel=id;
}
},
gridComplete: function() {
lastsel=undefined;
},
height:jq_numrows * jq_hr,
hidegrid: false,
editurl:url_post,
caption: jq_grid[0].caption,
loadui:"block"
});
I use the post id as parameter to select the record data on a server (where id='x').
The problem occurs when the data has been published in the column whose ColModel key:true, it is not updated
the rowid. Subsequent editions keep the id of the last reading, for example:
Data read:
id: C50
espcode: C50
espname: Users
First edit:
Grid -> Post
id: C50 -> C50
espcode: C50 -> U60
espname: Users -> Users
update table SET espcode = 'U60', espname = 'Users' WHERE espcode = 'C50' (ok)
Second edit:
Grid -> Post
id: C50 -> C50
espcode: U60 -> C70
espname: Users -> Users
update table SET espcode = 'C70', espname = 'Users' WHERE espcode = 'C50' (not ok, espcode = 'C50' not exist)
The possible solution I've found is to run jQuery('#grid0').trigger('reloadGrid'), in a function
within the parameter aftersavefunc of editRow function, to reload ID's:
jQuery('#grid0').editRow(id,true,'','','','',jq_reload);
function jq_reload(id, res){
if (res.statusText != 'OK') alert(jq_serverXHR(res));
jQuery('#grid0').trigger('reloadGrid');
}
Now with 3.6, I can use serializeRowData to add a value with data of rowid on last edit:
var rowKey;
var lastsel;
Query("#grid0").jqGrid({
url:url_get,
datatype: "xml",
colNames:[jq_cols[0].col_caption,jq_cols[0].col_caption],
colModel:[
{name:'espcode',index:'espcode', width:64, key:true, editable:true, align:"right",editoptions: {size:3, maxlength: 3}},
{name:'espname',index:'espname', width:210,editable:true,editoptions: {size:38, maxlength: 40}}
],
rowNum:jq_numrows,
autowidth : true,
shrinkToFit: false,
scrollOffset: 0,
gridview: true,
pager: jQuery('#pager'),
viewrecords: true,
serializeRowData:function(postdata) {
postdata.rowKey = rowKey;
return postdata;
},
onSelectRow: function(id){
if(id && id!==lastsel){
jQuery('#grid0').restoreRow(lastsel);
rowData = jQuery('#grid0').getRowData(id);
rowKey = rowData.espdate;
jQuery('#grid0').editRow(id,true);
lastsel=id;
}
},
gridComplete: function() {
rowKey = undefined;
lastsel= undefined;
},
height:jq_numrows * jq_hr,
hidegrid: false,
editurl:url_post,
caption: jq_grid[0].caption,
loadui:"block"
});
The problem:
The edited postdata in serializeRowData, show in grid.
I use a grid with a key column with date formatter:
colModel:[
{name:'espdate',index:'espdate', width:64, key:true, editable:true, align:"right",
formatter:'date', formatoptions:{srcformat:"Y-m-d",newformat:"j M Y"},
editoptions: {size:12, dataInit:function(el){$(el).datepicker({dateFormat:'d M yy',minDate: '+1', maxDate: jq_grids['#grid0'].maxDate ,onClose: function(){
$(this).focus();},changeMonth: true});}, readonly:'readonly'}},
{name:'espname',index:'espname', width:210,editable:true,editoptions: {size:38, maxlength: 40}}
],
I use the datepicker parse function (in a function) for post date in SQL format:
serializeRowData:function(postdata) {
postdata.espdate = ig_sqlDate(postdata.espdate);
postdata.rowKey = ig_sqlDate(rowKey);
return postdata;
},
If i use unformat option in colModel, getRowData retrieve data in srcformat, but inline edit post data in newformat.
02:36

Moderators
30/10/2007

Hello,
This is true, we post what is putted and your way is right.
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.
05:53

17/09/2009

Hello,
Sorry, I think badly explained, the problem is:
the data posted, show it in grid after post.
In last example sequence (dates with datepicker or manual entry in newformat):
Inline input: 15 Dic 2009 (ok)
Set Inline input with datepicker: 24 Dic 2009 (ok)
serializeRowData: function (postada) postdata.espdate: 24 Dic 2009 (ok??, The data in postdata should be in srcformat or option for it?)
espdate POST: 2009-12-24 (ok, after parse function ig_sqlDate(postdata.espdate))
Grid after post: 2009-12-24 (not ok)
Suggested sequence:
Inline input: 15 Dic 2009
Set Inline input with datepicker: 24 Dic 2009
serializeRowData: function (postada) postdata.espdate: 2009-12-24
Grid after post: 24 Dic 2009
Or postada is independent of data to show in grid,
Or postdata in srcformat, data to show in grid in newformat,
Or workaround: editRow(rowid, true, '', '', '','',aftersavefunc) cumbersome with multiple grids
Other options?
Best regards,
12:54

17/09/2009

Hello,
I've made the following changes to the code:
grid.inlinedit.js
+ 158 post_tmp = $.extend({},tmp);
- 161 data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData(tmp) : tmp,
+ 161 data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData(post_tmp) : tmp,
grid.formedit.js
+ 807 post_tmp = $.extend({},postdata);
- 811 data: $.isFunction(rp_ge.serializeEditData) ? rp_ge.serializeEditData(postdata) : postdata,
+ 811 data: $.isFunction(rp_ge.serializeEditData) ? rp_ge.serializeEditData(post_tmp) : postdata,
Now, in last example sequence (dates with datepicker):
Inline input: 15 Dic 2009 (ok)
Set Inline input with datepicker: 24 Dic 2009 (ok)
serializeRowData: function (postada) postdata.espdate: 24 Dic 2009 (ok)
espdate POST: 2009-12-24 (ok, after parse function ig_sqlDate(postdata.espdate))
Grid after post: 24 Dic 2009 (now ok)
I will continue doing tests on other formats (numbers, custom, etc.).
Best Regards,
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