Results 1 to 4 of 4

Thread: Model Form binding with XML

  1. #1
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    17
    Answers
    1
    Vote Rating
    0
      0  

    Default Unanswered: Model Form binding with XML

    Hi!

    I have a little problem.

    I have the following Script, where I want to get back a XML.
    But I dont get the values set inside the model & dont know how to get a XML back.

    Could you please help me out with this?



    Code:
    Ext.define('MyApp.view.MyFormPanel', {
        extend: 'Ext.form.Panel',
    
    
        config: {
            id: 'form',
            items: [
                {
                    xtype: 'fieldset',
                    modal: true,
                    title: 'TestFieldSet',
                    items: [
                        {
                            xtype: 'textfield',
                            label: 'Id',
                            name: 'number'
                        },
                        {
                            xtype: 'textfield',
                            label: 'Name',
                            name: 'name'
                        }
                    ]
                }
            ]
        },
    
    
        initialize: function() {
            this.callParent();
            var fields = [{name:'number', type:'string'},{name:'name', mapping:'name', type:'string'}];
    
    
            var ticketModel = Ext.define('TicketModel',
                {
                    extend:'Ext.data.Model',
                    config:{
                        fields:fields,
                        proxy: {
                            type: 'memory',
                            reader: {
                                type: 'xml',
                                record: 'data',
                                root:'root'
                            },
                            writer: {
                                type: 'xml',
                                record: 'data',
                                root:'root'
                            }
                        }
                    }
    
    
                });
    
    
            var ticketString = "<?xml version='1.0' encoding='UTF-8'?>"+
            "<root>"+
            "<data>"+
            "<number>12356478</number>"+
            "<name>Andreas</name>"+
            "</data>"+
            "</root>";
    
    
            var ticket = XMLtoDOM(ticketString);
    
    
            var newModel = Ext.create('TicketModel',ticket);
            this.setRecord(newModel);
    
    
           var ticket = XMLtoDOM(ticketString);
            function XMLtoDOM(xml){
                var xmlDom;
                if (window.ActiveXObject) { 
                    xmlDom = new ActiveXObject("Microsoft.XMLDOM"); 
                    xmlDom.async = "false"; 
                    xmlDom.loadXML(xml); 
                } else { 
                    xmlDom = new DOMParser().parseFromString(xml,"text/xml"); 
                }
                return xmlDom;
            }
        }
    });

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1296
      0  

    Default

    Why are you doing this? Why are you hurting performance to create XML client side and not just use an object?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Location
    Hamburg
    Posts
    1
    Vote Rating
    0
      0  

    Default

    Hi,
    additional info to this question above:
    We get the xml data using a soap request - the content is a xml string, that is being loaded to the store.

    after changing the data in die form, we want to get the updated contents back as an xml document (or string),
    so we can send this back to the soap server.

    it'd be much easier to use the document, so we have the format used in the input-data in the output data as well - an this format is the one the server expects.

    so creating an object before and create xml later from that object would be much heavier.

    so we need the information, how to get the data as xml /document or string) back to use that in further source.

  4. #4
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    17
    Answers
    1
    Vote Rating
    0
      0  

    Default

    We are creating the XML clientside just for testing and we need XML for our soap so we cn not use a object.

    Right now Im at a Point, were i write changes inside the raw document. That works.. but is not the right way, i guess.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •