• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[SOLVED] Checkbox Selection Issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] Checkbox Selection Issue

    I have added a checkbox to a grid. The user can then select the accounts to merge the account data with the selected Word template.

    Here is my HTML code to call my program and pass the information to process.

    Code:
                    var MultipleMergeDocument = function(){
                        var recs = mainPRMCLTLISTGrid.getSelectionModel().getSelections();
                        var postRecs = [];
                        Ext.iterate(recs, function(rec){
                            var obj = {
                                PMID: rec.data.PMID
                            };
                            postRecs.push(obj);
                        });
                        PEID = Ext.getCmp('DOCUMENTM').getValue();
                        Ext.DomHelper.append(document.body, {
                            tag: 'iframe',
                            frameBorder: 0,
                            width: 0,
                            height: 0,
                            css: 'display:none;visibility:hidden;height:1px;',
                            src: 'vvcall.pgm?sid=' + sid + '&opt=' + opt + '&pgm=prmergemb&action=mergeDocument&PEID=' + PEID + '&postRecs=' + Ext.encode(postRecs)
                        });
                        Ext.getCmp('MultipleMergeWindow').hide();
                        parent.showMessage('', '<b><center>Your document will be available shortly<\/b><\/center>');
                    };
    Here is my header in Google Chrome.
    Code:
    sid:7035632B81E6B6E759BA466401E00F8625EF2C41F69CE0F3A6E512C7F1D9C477
    opt:1059
    pgm:prmergemb
    action:mergeDocument
    PEID:1
    postRecs:[{
    Why is postRecs not showing up properly?

    Thanks in advance.

  • #2
    I checked to make sure postRecs has the right information.

    I added a console.log statement and it showed the following:
    Code:
    Accounts are [{"PMID":2891},{"PMID":4394}]
    These values are correct.

    Comment


    • #3
      Make sure to use urlEncode to convert things like apostrophes to safe characters for web transmission.

      In Ext the function is Ext.urlEncode(o);

      Pass it your JSON object.
      Last edited by eweiler; 02-20-2012, 12:39 PM.

      Comment


      • #4
        I changed my code as follows:

        Code:
                            Ext.DomHelper.append(document.body, {
                                tag: 'iframe',
                                frameBorder: 0,
                                width: 0,
                                height: 0,
                                css: 'display:none;visibility:hidden;height:1px;',
                                src: 'vvcall.pgm?sid=' + sid + '&opt=' + opt + '&pgm=prmergemb&action=mergeDocument&PEID=' + PEID + '&postRecs=' + Ext.urlEncode(postRecs)
                            });
                            Ext.getCmp('MultipleMergeWindow').hide();
                            parent.showMessage('', '<b><center>Your document will be available shortly<\/b><\/center>');
                        };
        Here is my header from Google Chrome:

        Code:
        sid:2EB07A552EC744C4F61E8AB8A1EB51906BCD2E0A355559A6EBFE52FFBCB0A48E
        opt:1059
        pgm:prmergemb
        action:mergeDocument
        PEID:1
        postRecs:[object Object]
        [object Object]:1

        Comment


        • #5
          What is Ext.urlEncode(postRecs) returning? Maybe it is adding duplicate & signs.

          Also, console.log your url to see what it is as a string before it is posted.

          Comment


          • #6
            This is what I get from the console.log statements.

            Code:
            Accounts are with encode[{"PMID":2891},{"PMID":4394}]
            Accounts are with urlEncode%5Bobject%20Object%5D=0&%5Bobject%20Object%5D=1

            Comment


            • #7
              Before the domHelper call put in this code and post the results:

              Code:
              console.log(typeof(postRecs));
              console.log(postRecs);
              console.log(Ext.encode(postRecs));
              console.log(Ext.urlEncode(postRecs));
              console.log(Ext.urlEncode(Ext.encode(postRecs)));

              Comment


              • #8
                Here is the results from the console:

                Code:
                object
                [Object,Object]
                [{"PMID":2891},{"PMID":4394}]
                %5Bobject%20Object%5D=0&%5Bobject%20Object%5D=1

                Comment


                • #9
                  This is what I think is happening:

                  You are passing an array to urlEncode, but it expects an object.

                  The thing to do here is go through your array end encode each value:
                  Code:
                  var parmArray = [];
                  Ext.each(postRecs, function(item, ix, orig) {
                     parmArray.push(Ext.urlEncode(item));
                  });
                  then your url should be built like this:

                  Code:
                  'vvcall.pgm?sid=' + sid + '&opt=' + opt + '&pgm=prmergemb&action=mergeDocument&PEID=' + PEID + '&postRecs=' + Ext.encode(parmArray)

                  If this doesn't work, let's get on a meeting to discuss it.

                  Comment


                  • #10
                    Thanks to Eric we got it figured. Here is my working code.

                    Code:
                                    var MultipleMergeDocument = function(){
                                        var recs = mainPRMCLTLISTGrid.getSelectionModel().getSelections();
                                        var postRecs = [];
                                        Ext.iterate(recs, function(rec){
                    						postRecs.push(rec.data.PMID);
                                            var obj = {
                                                PMID: rec.data.PMID
                                            };
                                        });
                    					PEID = Ext.getCmp('DOCUMENTM').getValue();
                    					var myUrl = 'vvcall.pgm?sid=' + sid + '&opt=' + opt + '&pgm=prmergemb&action=mergeDocument&PEID=' + PEID + '&postRecs=' + Ext.encode(postRecs);
                                        Ext.DomHelper.append(document.body, {
                                            tag: 'iframe',
                                            frameBorder: 0,
                                            width: 0,
                                            height: 0,
                                            css: 'display:none;visibility:hidden;height:1px;',
                                            src: myUrl
                                        });
                                        Ext.getCmp('MultipleMergeWindow').hide();
                                        parent.showMessage('', '<b><center>Your document will be available shortly<\/b><\/center>');
                                    };
                    For what ever reason when the DomHelper saw the first double quote in the postRecs variable it dropped it from that point on. We changed it to just an array instead of a JSON object. We changed the back end RPG from vvIn_JSON to vvIn_array and we get the data that we required.

                    Comment

                    Working...
                    X