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
Post dynamically additional data to the editurl
12/08/2008
09:18
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

(Newbee… appologies)

I need a qualifier that is changed by the user for all loads, reloads, edit, add, and delete of the grid. I have set up a var MemNo globally and used sccessfully in load, reload, edit and add: specified as postData:{wmemno:MemNo} in load, reload apears to pick it up dynamically and correctly, beforeSubmit function(row){row.wmemno=MemNo;} on the navGrid edit options (works on add as well without specifying it specifically for add), and tried to do the same for delete and it is not working.

I have tried editData in the navigator options… did not seem to respond, and delData in the delete options… did not respond. I realized that the input to beforeSubmit on edit and add are an object to which I have added my property but for delete it is just the row id and not an object.

I attach the load function and ask: how do I pass the MemNo dynamically to the editurl so that I can qualify the delete sql statement by this number in addition to the row id?

Many Thanks for any help!!

  function loadSpGrid() {
      jQuery(”#spgrid”).jqGrid({
        url:'s007.jsp',
        postData: {wmemno:MemNo},
        editurl:'s008.jsp',
        datatype: 'json',
        mtype: 'GET',
        colNames:['Start','End','Service','Earnings','Eligible'],
        colModel :[
          {name:'sdate',index:'start_date',width:80,
                         editable:true,editrules:{required:true}},
          {name:'edate',index:'end_date',width:80,
                         editable:true,editrules:{required:true}},
          {name:'service',index:'service',width:60,align:'right',
                         editable:true,editrules:{required:true,number:true}},
          {name:'earnings',index:'earnings',width:80, align:'right',
                         editable:true,editrules:{required:true,number:true}},
          {name:'eservice',index:'eligible_service',width:70,align:'right',sortable:false,
                         editable:true,editrules:{required:true,number:true}} ],
        pager: jQuery('#pager'),
        rowNum:10,
        rowList:[10,20,30],
        height:210,
        sortname: 'start_date',
        sortorder: “asc”,
        viewrecords: true,
        imgpath: 'js/themes/sand/images',
        caption: 'Financial data',
        subGrid: true,
        subGridRowExpanded: function(subgrid_id, row_id) {
          var subgrid_table_id = subgrid_id + “_t”;
          var pager_id = “p_” + subgrid_table_id;
          jQuery(”#”+subgrid_id).html(”<table id='”+subgrid_table_id+”' class='scroll'></table><div id='”+pager_id+”' class='scroll'></div>”);
          jQuery(”#”+subgrid_table_id).jqGrid({
            url:”s010.jsp?q=2&id=”+row_id+”&wmemno=”+MemNo,
            editurl:”s011.jsp?wmemno=”+MemNo+”&wspno=”+row_id,
            datatype: “json”,
            colNames:['Plan','Member contr.','Employer contr.'],
            colModel: [
              {name:"plan",index:"1",width:40,key:true,
                editable:true,editrules:{required:true}},
              {name:"memcon",index:"2",width:100,align:"right",sortable:false,
                editable:true,editrules:{required:true,number:true}},
              {name:"empcon",index:"3",width:110,align:"right",sortable:false,
                editable:true,editrules:{number:true}}
            ],
            pager: pager_id,
            height: '100%',
            rowNum:10,
            imgpath: 'js/themes/sand/images',
            sortname: '1',
            sortorder: “asc”
          }).navGrid(”#”+pager_id,{search:false},
               {height:200,reloadAfterSubmit:false},
               {height:200}, //add options
               {reloadAfterSubmit:false}, //del options
               {} //search options
             );
        }
      }).navGrid('#pager',
          {search:false}, //options
          {height:200,reloadAfterSubmit:false,
             beforeSubmit:function(row){
               row.wmemno = MemNo;
               return true;
             } //works on add as well but not delete.
          }, //edit options
          {height:200}, //add options
          {reloadAfterSubmit:false,
             beforeSubmit:function(row){
               jQuery(”#spgrid”).setGridParam({delData:{wmemno:MemNo}});
               return true;
             }
          }, //del options
          {} //search options
          );
  }

13/08/2008
05:09
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Refer to documentation how to use delData.

You should use onclickSubmit event for this - something like

// for delete options

onclickSubmit : function(params}

return {wmemno:MemNo}

}

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/08/2008
06:40
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

Thank you Tony,

I have tried the onclickSubmit before and the value received in wmemno was null, I tried it again now and still the value passed is null. There is a value in MemNo.

14/08/2008
03:14
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

To resolve this make alert for the variable before the return in the event

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.

18/09/2008
08:29
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

I have added the alert to all three (edit, add, delete) onclickSubmit and none shows up. How is it that my event function is not executed?

      }).navGrid('#pager',
          {search:false}, //options
          {height:200,reloadAfterSubmit:false,
             onclickSubmit: function(params) {
               alert("wmemno="+MemNo);
               return {wmemno:MemNo}; 
             }
          }, //edit options
          {height:200,
             onclickSubmit: function(params) {
               alert("wmemno="+MemNo);
               return {wmemno:MemNo}; 
             }
          }, //add options
          {reloadAfterSubmit:false,
             onclickSubmit: function(params) {
               alert("wmemno="+MemNo);
               return {wmemno:MemNo}; 
             }
          }, //del options
          {} //search options
          );
  }

(Sorry for the timelag, I have cleaned up the development around the grid and now I am back to it).

The beforeSubmit is functional and by appending a new property to the row I get the value in the jsp to process and it is a valid approach however, the Delete is not working like this since it does not pass the row, just the row_id. I tried to set the delData with no success.

18/09/2008
10:24
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

What values are posted when you use delete?

It is very strange, since the approach is the same as those in edit.

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.

18/09/2008
12:55
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

My grid displays all records of one membership, the table has records of multiple memberships. Each row is one record with an id assigned within the same membership number. The row_id is unique to the grid but not to the table. In the table in order to delete a row I need the membership number plus the row_id. For edit and add the grid is passing all the values of the row in the posted data, for delete it passes only the row_id and the action {oper: "del"}. Therefore, in edit and add I attach an additional property to the row and thus the jsp receives the membership number, in delete attaching a membership number as an additional property does not make it available to the jsp since the row is not passed as posted data. I thought that the delData property of the grid would accomplish this but I tried both static in the construction of the grid and dynamic in the beforeSubmit with no success.

If onclickSubmit is not called, in my case, and then if I use the beforeSubmit to set the delData with {wmemno: MemNo} and it is not posted to the editurl then how can I post the data for delete? I could have added it to the url as Get data but it would be static and once the membership number is changed it would stick to the first one set.

The only other way I can think of is: in the beforeSubmit, call (ajax or similar) the editurl jsp direclty with the row_id and membership number posted to it.

18/09/2008
13:06
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

maybe this will help. (for delete)

onclickSubmit: function(params){

var gsr = $("#grid_id").getGridParam('selrow');

var sdata = $("#grid_id").getRowData(gsr);

return {wmemno: sdata.MemNo}

}

In my project this work  whitout problems.

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.

18/09/2008
13:15
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Shimon I had a similar issue, however and I am not sure if this solves your problem, if the membership number is embedded in the HTML somewhere can you not just get it via a jQuery selector?

/Membership/Delete?memNo='+$(currentRow '+ input#memNo').val()

meaning currentRow could be set up to look for the current row's key (of course if button on each row other wise if check box with delete button at bottom of page will change selector slightly):

currentRow = $(this).parent().parent (as button in td in tr)

Let me know if this helps.

18/09/2008
14:12
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

Hi Tony,

The MemNo is a global variable to the page and if my onclickSubmit was invoked then the return {wmemno: MemNo} would have worked. The MemNo is not a field in the row. If I can get onclickSubmit to work I should hope that the returned value is added to the posted data.

Could you give me a hint to look for why my onclickSubmit is not invoked?

Renso: MemNo is a global variable and I have it through the page but it is the ajax invoked url that needs it as an input. However your suggestion made me see that I can add it to the editurl and every time it changes I should setGridParam({editurl: 'myjsp.jsp?wmemno='+MemNo}) and it works

Thank you Tony and Renso. I still think that the onclickSubmit is a nicer looking solution if I can make it to work.

18/09/2008
16:25
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

Shimon, right on! Thanks for gettnig back to us.

19/09/2008
00:56
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Really very strange. To test find delGridRow method, then find

if( typeof p.onclickSubmit === 'function' )

p.delData = p.onclickSubmit(p) || {};

after this make

alert(p.delData.wmemno) ;

After this find

var postd = $.extend({oper:"del", id:postdata},p.delData);

and then make the same

alert(postd.wmemno)

See the results.

I will try to test this again.

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.

19/09/2008
06:18
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

Hi Tony,

I found the method delGridRow in grid.formedit.js but there is no if( typeofp.onclickSubmit === 'function') in it. Yes, there is beforeSubmit and afterSubmit but no onclickSubmit... I guess I should download again. I can't see any version identifier in the file to send you. Should I mail you the file?

I thank you and appreciate your involvement,

Shimon

19/09/2008
07:20
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

you should download the latest version for

Download section here (3.2.4)

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.

19/09/2008
10:17
Avatar
Shimon
Member
Members
Forum Posts: 7
Member Since:
12/08/2008
sp_UserOfflineSmall Offline

Thank you Tony, it works and the bonus is the tree grid. I can see now the line with the if (typeof onclickSubmit...

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
28 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