View Poll Results: Was this useful?

Voters
0. You may not vote on this poll
  • Yes

    0 0%
  • No

    0 0%
Multiple Choice Poll.
Results 1 to 2 of 2

Thread: MVC : How do I save checkbox values or responses in to a Store?

  1. #1

    Default MVC : How do I save checkbox values or responses in to a Store?

    I have a toolbar with several button menus. here is one of the button's menu.

    I want to collect the checked values and checkbox name and save them to a store.



    {
    xtype: 'checkboxgroup',
    id: 'cbg',
    vertical: true,
    layout: 'column',
    defaultType: 'container',
    items:
    [
    {
    columnWidth: 1,
    items:
    [
    {
    xtype: 'checkboxfield', boxLabel: 'All', name: 'all_dataType', id: 'all_dataType', inputValue: 'true',
    scope: this,
    handler: function(field, value)
    {
    if (value)
    {
    Ext.getCmp('bathydatatype').setValue(1);
    Ext.getCmp('globaldatatype').setValue(1);
    Ext.getCmp('topodatatype').setValue(1);
    }
    else
    {
    Ext.getCmp('bathydatatype').setValue(0);
    Ext.getCmp('globaldatatype').setValue(0);
    Ext.getCmp('topodatatype').setValue(0);
    };
    }// end handler
    },
    {xtype: 'checkboxfield', boxLabel: 'Bathymetrics', id: 'bathydatatype', name: 'bathymetrics_dataType', inputValue: 'true'},
    {xtype: 'checkboxfield', boxLabel: 'Global', id: 'globaldatatype', name: 'global_dataType', inputValue: 'true'},
    {xtype: 'checkboxfield', boxLabel: 'Topography', id: 'topodatatype', name: 'topography_dataType', inputValue: 'true'}
    ]
    }




    Ext.define('GoApp.store.ds',
    {
    extend: 'Ext.data.Store',

    // cross domain protocols are required
    // requiring an object without using that object, fails the script
    requires: ['Ext.data.proxy.JsonP'],
    model: 'GoApp.model.Post',
    pageSize: 10,
    autoLoad: true,
    autoSync: true,

    // server communication
    proxy:
    {
    type: 'jsonp',
    callbackkey: 'results',
    url: 'http://172.18.100.96/capstone/locate/return/',
    reader:
    {
    type: 'json',
    root: 'results'
    }
    }
    });

    Ext.define("GoApp.model.Post",
    {
    extend: 'Ext.data.Model',

    requires: ['Ext.data.Field'],

    fields:
    [

    { name: 'dataType', type: 'auto' }
    ]
    });

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi--

    I've included a Fiddle (below) which demonstrates one approach. The basic idea is that I add a "ref" to the controller to provide easy access to the checkbox group (and avoid using a hard-coded "id"). In the controller, I added a listener for the "Save" button, and in the handler I do the following:
    • Get reference to checkbox group and target store
    • Retrieve checked items via getChecked()
    • Loop over checked items and add data to store
    Of course, you don't necessarily need the controller...I just did that because your subject line mentioned "MVC".

    I hope that helps!
    Thanks
    Joel


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
  •