Results 1 to 5 of 5

Thread: loading form data (checkbox & radio) with json

  1. #1

    Question loading form data (checkbox & radio) with json

    Hi, guys
    I am trying to load form data (checkbox & raido),
    The following is part of my ext code.

    Code:
    {
        	xtype: 'checkboxgroup',
        	fieldLabel: 'test 1',
        	width: 300,
    	items: [
    		{boxLabel: 'test 1 1', name: 'dss.test1', checked: true},
    		{boxLabel: 'test 1 2', name: 'dss.test2', checked: true}
    	]
    }
    
    
    {
    	fieldLabel: 'chance',
    	width: 220,
    	xtype: 'radiogroup',
    	items: [
    		{boxLabel: 'test3 1', name: 'dss.test3', inputValue: 1},
    		{boxLabel: 'test3 2', name: 'dss.test3', inputValue: 2},
    		{boxLabel: 'test3 3', name: 'dss.test3', inputValue: 3}
    	]
    }

    The following is json response:
    Code:
    {
    	success: true,
    	data: {
    		"dss.test1": "on",
    		"dss.test2": "on",
    		"dss.test3": "1"
    	}
    }
    But the form just does not load the correct data, while combox always load correctly.
    Does anyone know why?

    Thanks.
    Dennis

  2. #2

    Default

    Besides,
    How to set the mapping between the json response and the ext components(like combobox)?
    I tried like this:
    Code:
    reader: new Ext.data.JsonReader({
    	record: 'data',
    	successProperty: 'success'
    }, [
    	{name: 'dss.test1', mapping: 'test1'},
    	{name: 'dss.test2', mapping: 'test2'},
    	{name: 'dss.test3', mapping: 'test3'}
    ]),
    but it does not work out.

    Thanks.
    Dennis

  3. #3
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    The XXXGroup fields are fields in their own right with setters.

    Drop this page into examples/anywhere

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
    <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="../../ext-all-debug.js"></script>
    <script type="text/javascript">
    Ext.onReady(function() {
        fp = new Ext.FormPanel({
            title: 'Test',
            style: {
                margin: '10px'
            },
            frame: true,
            height: 400,
            width: 600,
            items: [{
                xtype: 'checkboxgroup',
                name: 'cbg',
                fieldLabel: 'test 1',
                width: 300,
                items: [
                    {boxLabel: 'test 1 1', name: 'dss.test1', checked: false},
                    {boxLabel: 'test 1 2', name: 'dss.test2', checked: false}
                ]
            }, {
                xtype: 'radiogroup',
                name: 'rg',
                fieldLabel: 'chance',
                width: 220,
                items: [
                    {boxLabel: 'test3 1', name: 'dss.test3', inputValue: 1},
                    {boxLabel: 'test3 2', name: 'dss.test3', inputValue: 2},
                    {boxLabel: 'test3 3', name: 'dss.test3', inputValue: 3}
                ]
            }],
            renderTo: document.body
        });
        f = fp.getForm();
    });
    </script>
    </head>
    <body>
    </html>
    Then try this on the Firebug command line and see the form load:

    Code:
    f.setValues({
        cbg: [true, true],
        rg: 1
    });

  4. #4

    Default

    Thanks,

    The checkboxgroup did loaded, but not the radiobox.

    Dennis
    Attached Images Attached Images
    • File Type: png r.png (8.0 KB, 124 views)

  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Maybe you have old code. Because it "worked for me"

Posting Permissions

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