Forum
23:22
19/10/2009
I have 4 fields defined in the grid with only 2 of the field displayed (works great). When I edit the row in the Form it works fine as I find the hidden id field and add it to the poste data. My problem is when you move to another record within the Form. I can no longer determine the true record ID.
I've looked at the createData routine and it DOES NOT add the hidden fields into the form unless they are Editable. The documentation says they will be sent but they aren't. I looked at v 3.6 and it has some new feature of looking for the name to not equal 'nm' (dont' know why yet).
I can disable the ability to move to another record while in the form but it's a nice feature that would be very helpful.
Doug
02:52
Moderators
30/10/2007
Hello,
Just tested your case. It works for me ok. In order to resolve I need a link to the problem or at leat the code with the data.
Thanks.
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.
08:44
19/10/2009
Tony,
I pulled the code with firebug so it's not formatted very well. But, you'll see 4 fields with the 1st and 4th field marked as hidden. They do not sho up on the edit form.
I have an additional bug (sorry to list it here but it may be related). The first record I delete recieves the "exParams" that I add. The second time I delete without refreshing the screen the first data is sent, even though the exParams have been updated with the correct values.
I've been to Sophia a few times, nice place. Can't speak the language but enjoy the Shopska salads.
$("#list9").jqGrid({
url:"/baserules/code/griddata?layout=internal&cd_table=L1",
datatype: "xml",
type: "GET",
colNames:[ "ID", "Code", "Description", "table id"],
colModel :[
{ name: "cd_id", index: "cd_id", width: "30", align:"left", hidden:true, editable: false, editrules:{edithidden:false} },
{ name: "cd_code", index: "cd_code", width: "120", align:"left", editable:true, editrules:{edithidden:true} },
{ name: "cd_description", index: "cd_description", width: "200", align:"left", editable:true, editrules:{edithidden:true} },
{ name: "cd_table", index: "cd_table", width: "20", align:"left", hidden:true, editable: false, editrules:{edithidden:false} } ],
rowNum:-1,
imgpath: "/css/jqGrid-themes/basic/images",
pager: $("#list9pager"),
sortname: "%user%",
viewrecords: true,
sortorder: "",
pginput: true,
editurl:"/baserules/code/savedata",
height:265
}).attr( "ts_savedata", "{ 'cd_table': 'L1' }");
$("#list9add").click(function(){
sdata = $("#list9").attr("ts_savedata");
props = {};
//eval(sdata);
eval( 'x = ' + sdata);
// jqgrid needs editData set to return to host
props['editData'] = x;
$("#list9").editGridRow( "new", props );
});
$("#list9edit").click(function(){
editRow( "#list9" );
});
$("#list9clicker").dblclick(function(){
editRow( "#list9" );
});
});
function upit( cellvalue, options, cellobject)
{
return cellvalue.toString().toUpperCase();
}
function deleteRow( gridId )
{
var gr = $(gridId).getGridParam("selrow");
if( gr != null ) {
var data = $(gridId).getRowData( gr );
exData = {};
var i = 0;
for(var key in data)
{
if (i == 0) exData[key] = data[key];
break;
}
var ref = $("#delete").attr("href") + gr;
$(gridId).delGridRow(gr,
{top: 200, left:300, width:320, height:120,
mtype: "POST",
msg:"Delete record?",
processData: "Processing...",
reloadAfterSubmit:true,
delData:exData
} );
return true;
}
else {
alert("Please select a row.");
return false;
}
}
function clickedSubmit( options, gridId )
{
exParam = {};
var gr = $(gridId).getGridParam("selrow");
if( gr != null ) {
var data = $(gridId).getRowData( gr );
var i = 0;
for(var key in data)
{
if (i == 0) exParam[key] = data[key];
break;
}
}
return exParam;
}
function editRow( gridId )
{
var gr = $(gridId).getGridParam("selrow");
if( gr != null ) {
var data = $(gridId).getRowData( gr );
exParam = {};
var i = 0;
for(var key in data)
{
if (i == 0) exParam[key] = data[key];
break;
}
$(gridId).editGridRow( gr,{ editData: exParam,
onclickSubmit: function(options) { clickedSubmit( options, gridId ) }
} );
return true;
}
else {
alert("Please select a row.");
return false;
}
}
Doug
10:23
19/10/2009
Mark,
Thanks that worked! The hidden fields are on the form. Unfortunately, the data posted to the server is incorrect. The posted data for the hidden fields is the first record displayed in the form. As you scroll those data elements aren't being updated. I'm still in the same situation as I am with the delete function. The hidden elements can only be set once.
Firebug - net tab
Post header for first record
cd_code | 2 |
cd_description | |
cd_id | 28 |
cd_table | L1 |
id | 5 |
oper | edit |
(cd_table and cd_id are hidden)
I scroll back to the previous record and hit submit and get
cd_code | 1 |
cd_description | |
cd_id | 28 |
cd_table | L1 |
id | 4 |
oper | edit |
The code, description and your id are all correct but the 2 hidden fields reflect what was in the first record, specifically cd_id which is the primary key.
Doug
13:21
Moderators
30/10/2007
IMHO, the problem is in clickedSubmit function, which can overwrite the posted values from the form. To test just disable this function.
Regards
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.
13:38
19/10/2009
Still doesn't work with the clickedSubmit function disabled. In fact, I didn't add the clickedSubmit until I had the problem.
Just to be clear. The delGridRow and editGridRow functions both won't update the hidden fields after the first submit.
So, delGridRow works the first time but never again until a page refresh.
The editGridRow works if you don't scroll off the current record.
Doug
13:50
30/07/2009
So a quick check suggests this is working. I've also looked at the code, and it seems to do exactly the right thing...
One thought - are you sure your database didnt get corrupted by your earlier experiments?
ie is it possible that the cd_id and cd_table fields really are the same for those two records (even thought they should be different).
Mark
14:53
19/10/2009
Ok, I found a solution but don't fully understand why the original code doesn't work.
I changed out line 1187 in grid.formedit.js on v3.5.2
from
var postd = $.extend({oper:"del", id:postdata}, p.delData, onCS);
to
var postd = $.extend({oper:"del", id:postdata}, rp_ge.delData, onCS);
and it works. After the modal dialog is presented "p" comes back with the old delData.
03:16
Moderators
30/10/2007
Hello,
Aha. Thanks. Fixed in the upcomming 3.6 release.
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.
08:59
Moderators
30/10/2007
Hello,
editGridRow is OK. Check your code. Just for your information yhe posted data is extended in the following way
postdata = $.extend(postdata,rp_ge.editData,onclickSubmitData);
Maybe in your code editData has values which are old.
If you use FireBug find the postIt function and see the values just before the expression above
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:
72 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