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

[HELPED] question on use of Metaform

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

  • [HELPED] question on use of Metaform

    I'm using the extension from (Saki - see Extjs.eu) metaform in order to generate a window with a variable number of fields on it.

    Everything is working as expected...
    except that when adding a 'textarea' field, and that fields contains a CRLF that user has entered, I get an error because of invalid Json... (see prtsrn)

    i think the problem cas be easily solved by replacing the special chars by their html countervalue (i.e crlf should become \n)

    Code:
    var getRecTemp = function(Lmode) {
        mode = Lmode;
        Ext.Ajax.request({
            url: 'vvcall.pgm',
            params: {
                pgm: 'TDTK10R',
                action: 'getForm1',
                machine: currentRecord.data.MINEQUIP,
                template: DataStoreDetail.getAt(globalRowIndex).get('XDXTEXT')
                },
            success: function(response) {
                var check = response.responseText;
                if (check) {
                    var data = Ext.util.JSON.decode(response.responseText);
                    if (data.SUCCESS == '1') {
                        var getForm_machine = data.MACHINE;
                        var getForm_template = data.TEMPLATE;
                        var winTempl = new Ext.Window({
                            id: 'WinTempl',
                            layout: 'fit',
                            width: 750,
                            height: 400,
                            modal: true,
                            title: 'Template:' + getForm_template + '/    Machine:' + getForm_machine,
                            items: {
                                xtype: 'metaform',
                                autoScroll: true,
                                url: 'vvcall.pgm',
                                baseParams: {
                                    pgm: 'TDTK10R',
                                    action: 'getForm',
                                    machine: getForm_machine,
                                    template: getForm_template
                                },
                                buttons: [{
                                    text: 'Save',
                                    handler: function() {
                                        Ext.getCmp('WinTempl').items.get(0).getForm().submit({
                                            success: function() {
                                                winTempl.close();
                                            }
                                        });
                                    }
                                }]
                                }
                        });
                        winTempl.show();
                    }
                }
            },
    
            failure: function(response) {
                Ext.getBody().unmask();
                Ext.Msg.alert('Error', 'Function is not allowed');
            }
        });
    };

    The link to the metaform code http://www.sencha.com/forum/showthre...ed-from-server

    As always, i think i'm close to the solution, but elas in this case... this is beyond my current javascript/extjs knowledge..

    i know it needs to be solved by replacing the 'special' values by their json-friendly-counterpart (i.e CRLF by \n) but my problem is: where should i put the code in !!!

    i hope someone could help me on that !
    Attached Files

  • #2
    Hi Thierry -

    How are you sending your data back to the front-end? What back-end procedure are you using (execSQLToJson, toJson, etc...)?

    Comment


    • #3
      That's just my problem... i can't find out how it is sent back to the server..

      i think it's sent from within the metaform.js (which does an extension of the ext.form.formpanel)
      and that it's just using the submit to send back to the server...

      i'm not experienced with the principles of extended classes and i just can't figure out where i need to insert to replace code?

      Comment


      • #4
        Hi Thierry -

        I am still not entirely clear at what point you are experiencing this error?

        Is the invalid JSON being sent back from the server when you are attempting to build/populate your form?

        I notice that the screenshot you posted shows a success of true followed by metadata so I assume this is at form creation?

        Or does this error occur on your submit of the form? If so, is it on the return of the success from the server?

        Comment


        • #5
          TheirryC,

          Did you ever figure out how the inner workings of the MetaForm were operating in your code?

          Comment

          Working...
          X