Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Hidden fields not posted during editGridRow
19/10/2009
23:22
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

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

20/10/2009
02:52
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

20/10/2009
08:44
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

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

20/10/2009
09:54
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

I think you want the fields to be editable:true, hidden:true, edithidden:false.

Mark

20/10/2009
10:23
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

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

20/10/2009
12:52
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

Sounds like a bug...

I've been assuming this is working for me, but havent tested this scenario beyond things looking about right. I may have the same problem in my grid - I'll have to test it.

Mark

20/10/2009
13:21
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

20/10/2009
13:38
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

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

20/10/2009
13:50
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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

20/10/2009
14:00
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

cd_id is an autocomplete field in mysql and I did validate it before running the test. In the example the cd_code=1 has a cd_id=27 not 28

Also, the weird part to me is when I had the clickedSubmit turned on I was filling the exParam with the correct data but it wasn't being posted.

20/10/2009
14:53
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

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.

21/10/2009
03:16
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

21/10/2009
08:49
Avatar
dpeterman
Member
Members
Forum Posts: 10
Member Since:
19/10/2009
sp_UserOfflineSmall Offline

Tony,

The lines listed above were for the delgridrow, does 3.6 fix the edit issue as well? I'm assuming it's something similar?

Doug

21/10/2009
08:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information