1. #1
    Sencha User kantha.exe's Avatar
    Join Date
    May 2012
    Location
    India, Banglore
    Posts
    24
    Vote Rating
    -1
    kantha.exe is an unknown quantity at this point

      -1  

    Default Unanswered: Problem with Updating Store

    Unanswered: Problem with Updating Store


    HI I am using ext4 and javaSpring MVC

    ... .... ... ... ...
    record.set({
    menuKey:menuKey,
    addYN:addYN,
    editYN:editYN,
    viewYN:viewYN,
    deleteYN:deleteYN,
    exportYN:exportYN

    });

    RoleMenuLinksStore.add(record);

    }

    }

    RoleMenuLinksStore.sync(); // Showing Error ... Uncaught TypeError: Cannot call method 'indexOf' of undefined

    I mentioned Writer also but its not calling controller....?

    any idea...

    Thank You...

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,882
    Answers
    653
    Vote Rating
    439
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    You should be able to add records as follows:

    Code:
    var rec = [{ name: 'Sencha', email: 'support@sencha.com', change: 0 }];
    store.add(rec);
    Scott.

  3. #3
    Sencha User kantha.exe's Avatar
    Join Date
    May 2012
    Location
    India, Banglore
    Posts
    24
    Vote Rating
    -1
    kantha.exe is an unknown quantity at this point

      0  

    Default store.add(rec)

    store.add(rec)


    I am updating records.....so Add records means adding new Records or what ..?
    or it will update existing record with new values like updating.......?

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,882
    Answers
    653
    Vote Rating
    439
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    RoleMenuLinksStore.add(record);
    You first post referenced adding of records, so this is what I referenced.

    What are you looking for? record.set(values) will update the record.

    Scott.

  5. #5
    Sencha User kantha.exe's Avatar
    Join Date
    May 2012
    Location
    India, Banglore
    Posts
    24
    Vote Rating
    -1
    kantha.exe is an unknown quantity at this point

      0  

    Default Updating Store

    Updating Store


    Oh Ok

    Actually I am Updating store in grids dynamically...
    I have design as in attachment Image.
    I contains 4 grids accordionpannel with check boxes....
    on click of save it should update records .....the code as shown below

    Ext.QuickTips.init();




    Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.state.*',
    'Ext.ux.CheckColumn',
    'Ext.form.*',
    'Ext.layout.container.Absolute',
    'Ext.window.Window',
    'Ext.panel.Panel',
    'Ext.chart.series',
    'Ext.data.Record.*',
    'Ext.data.Model',
    'Ext.window.MessageBox'

    ]);


    Ext.Loader.setPath('Ext.ux', '../ux');
    Ext.Loader.setConfig({
    enabled: true
    });


    /*private long key;
    private Integer moduleKey;
    private String primaryName;
    private String secondaryName;
    private String primaryDesc;
    private String secondaryDesc;
    private String menuUrl;
    private Integer parentKey;
    private Integer seqNo;
    private Modifiers modifiers;*/
    Ext.define('Menu',{


    extend: 'Ext.data.Model',


    fields: [
    {
    name:'key',
    type:'int'
    },
    {
    name:'moduleKey',
    type:'int'
    },
    {
    name:'primaryName',
    type:'string'
    },
    {
    name:'secondaryName',
    type:'string'
    },
    {
    name:'primaryDesc',
    type:'string'
    },
    {
    name:'secondaryDesc',
    type:'string'
    },
    {
    name:'menuUrl',
    type:'string'
    },
    {
    name:'parentKey',
    type:'int'
    },
    {
    name:'seqNo',
    type:'int'
    },
    {
    name : 'modifiers',
    convert : function(value, row) {
    var obj = {
    effstartdate : value == null ? '' : value.effstartdate,
    effenddate : value == null ? '' : value.effenddate,
    remarks : value == null ? '' : value.remarks,
    status : value == null ? '' : value.status,
    entryDate : value == null ? '' : value.entryDate,
    entryUser : value == null ? '' : value.entryUser,
    updateDate : value == null ? '' : value.updateDate,
    updateUser: value == null ? '' : value.updateUser
    };
    return (value == null) ? '' : obj;
    },
    type : 'string'
    }
    ]


    });


    var menuStore = Ext.create('Ext.data.Store', {
    id: 'menuStore',
    model: 'Menu',
    autoLoad: true,
    proxy: {
    type: 'ajax',


    api : {

    read : 'menumasterParent/view.action'

    },
    reader: {
    type: 'json',
    root: 'data',
    idProperty: 'key',
    successProperty : 'success',
    messageProperty : 'message'
    }

    }
    });




    /*private long key;
    private Integer roleKey;
    private Integer menuKey;
    private char addYN;
    private char editYN;
    private char deleteYN;
    private char viewYN;
    private char exportYN;

    private Menu menu;*/
    Ext.define('RoleMenuLinks',{


    extend: 'Ext.data.Model',


    fields: [
    {
    name:'key',
    type:'int'
    },
    {
    name:'roleKey',
    type:'int'
    },
    {
    name:'menuKey',
    type:'string'
    },
    {
    name:'addYN',
    type:'char'
    },
    {
    name:'editYN',
    type:'char'
    },
    {
    name:'deleteYN',
    type:'char'
    },
    {
    name:'viewYN',
    type:'char'
    },
    {
    name:'exportYN',
    type:'char'
    },
    {
    name:'menu',
    convert : function(value, row) {

    return (value == null) ? '' : value.primaryName;
    },
    type : 'string',
    useNull : true

    }
    ]


    });


    var roleMenuProxy = new Ext.data.HttpProxy({

    type: 'ajax',

    api : {

    read : 'RoleMenuLinksForChilds/view.action',
    update:'RoleMenuLinks/update.action'

    },
    reader: {
    type: 'json',
    root: 'data',
    idProperty: 'key',
    successProperty : 'success',
    messageProperty : 'message'
    },
    writer: {
    type: 'json',
    writeAllFields : true,
    encode:false

    }
    });


    var RoleMenuLinksStore = Ext.create('Ext.data.Store', {

    extend: 'Ext.data.Store',
    id: 'RoleMenuLinksStore',
    model: 'RoleMenuLinks',

    proxy: roleMenuProxy

    });




    //--------------------------------------------------------------------------








    var panelCount=0;
    var myIds = [];
    var gridNameArray=[];
    Ext.onReady(function() {





    var roleKey=document.getElementById('roleKey');

    var exportYN=document.getElementById('exportYN');
    var addYN=document.getElementById('addYN');
    var editYN=document.getElementById('editYN');
    var viewYN=document.getElementById('viewYN');
    var deleteYN=document.getElementById('deleteYN');
    var menu=document.getElementById('menu');

    var roleMenuLinkTitle=document.getElementById('roleMenuLinkTitle');



    /** Menu Store */
    // menuStore.on('load',function(store, records, options){
    //
    // panelCount=store.getTotalCount();
    //
    // for(var i=0;i<panelCount;i++){
    //
    //
    //
    //
    // var grid = addPanels(i,store.getAt(i).get('primaryName'),store.getAt(i).get('key'),roleKey.value,RoleMenuLinksStore);
    //
    // }
    //
    // alert(" out ...");
    // mapTransations(store,store.getAt(0).get('primaryName'));
    //
    // });
    /** Menu Store */




    /** Panel */
    //var grid1 = TestGrid();
    var pan=Ext.create('Ext.panel.Panel',
    {
    xtype: 'panel',
    height: 561,
    width: 1100,
    x:0,y:0,
    frame:true,
    layout: {
    type: 'accordion'
    },
    title: roleMenuLinkTitle.value,
    dockedItems: [
    {
    xtype: 'toolbar',
    height: 31,
    dock: 'top',
    items: [
    {
    xtype: 'button',
    text: 'Save/Update',
    iconCls : 'icon-save',
    handler:function(){

    saveAndUpdate();

    }
    },
    {
    xtype: 'displayfield',
    value: '',
    fieldLabel: '',
    width:250
    },

    {
    xtype: 'button',
    text: "Back",
    iconCls : 'icon-previousnav',
    handler : function() {

    history.go(-1);

    }
    }
    ]
    }
    ]



    });
    pan.render("roleMenuLink");
    /** Panel */
    menuStore.on('load',function(store, records, options){

    panelCount=store.getTotalCount();

    for(var i=0;i<panelCount;i++){

    var RoleMenuLinksStore1 = Ext.create('Ext.data.Store', {
    extend:'Ext.data.Store',
    id: 'RoleMenuLinks'+i,
    model: 'RoleMenuLinks',
    autoLoad: false,
    proxy: roleMenuProxy
    });

    RoleMenuLinksStore1.load({
    params:
    {
    menuIDtore.getAt(i).get('key'),
    roleKey:roleKey.value
    }
    });


    var grid = TestGrid(i,store.getAt(i).get('primaryName'),RoleMenuLinksStore1);

    myIds.push(grid.getId());

    var pannels = Ext.create('Ext.panel.Panel',
    {
    xtype: 'panel',
    height: 561,
    width: 829,
    id:'pan'+i,
    titletore.getAt(i).get('primaryName'),
    items: [

    grid

    ]


    });
    pan.add(pannels);
    }// end loop

    /*RoleMenuLinksStore1.load(function(records,operation,success){


    for(var i=0;i<20;i++)
    alert(" Method >> "+records[i].data.key);

    });
    */
    checkk(myIds,grid);


    /* var storeTest = Ext.getCmp('MastersID').getStore();

    storeTest.on('load',function(store){
    for(var i = 0;i<store.getTotalCount();i++)
    {
    store.getAt(i).set('addYN',store.getAt(i).get('addYN')=='Y'?true:false);
    store.getAt(i).set('editYN',store.getAt(i).get('editYN')=='Y'?true:false);
    store.getAt(i).set('exportYN',store.getAt(i).get('exportYN')=='Y'?true:false);
    store.getAt(i).set('deleteYN',store.getAt(i).get('deleteYN')=='Y'?true:false);
    store.getAt(i).set('viewYN',store.getAt(i).get('viewYN')=='Y'?true:false);
    }

    });

    storeTest = Ext.getCmp('TransactionsID').getStore();*/



    });

    });


    function TestGrid(index,menuname,store)
    {
    var sm = new Ext.selection.CheckboxModel({
    listeners: {
    selectionchange: function (selectionModel, selected, options) {

    //selectionModel.view.refresh();
    }
    }
    });



    var grid = Ext.create('Ext.grid.Panel', {

    xtype: 'grid',
    // title: 'My Grid Panel',
    id:menuname+"ID",
    storetore,
    selModel: sm,
    columns: [

    {
    xtype: 'gridcolumn',
    dataIndex: 'menu',
    width: 200,
    header: menu.value
    },
    {
    xtype: 'checkcolumn',
    dataIndex: 'addYN',
    width: 100,
    header:addYN.value

    },
    {
    xtype: 'checkcolumn',
    dataIndex: 'editYN',
    width: 100,
    header:editYN.value

    },
    {
    xtype: 'checkcolumn',
    dataIndex: 'deleteYN',
    width: 100,

    header: deleteYN.value
    },
    {
    xtype: 'checkcolumn',
    dataIndex: 'viewYN',
    width: 100,
    header:viewYN.value

    },
    {
    xtype: 'checkcolumn',
    dataIndex: 'exportYN',
    width: 100,
    header: exportYN.value
    }
    ],
    viewConfig: {


    }


    });
    return grid;
    }




    function checkk(myIds,grid){


    //alert(myIds.length);


    for(var i=0;i<myIds.length;i++){

    var storeTest = Ext.getCmp(myIds[i]).getStore();

    storeTest.on('load',function(store){
    for(var i = 0;i<store.getTotalCount();i++)
    {

    store.getAt(i).set('addYN',store.getAt(i).get('addYN')=='Y'?true:false);
    store.getAt(i).set('editYN',store.getAt(i).get('editYN')=='Y'?true:false);
    store.getAt(i).set('exportYN',store.getAt(i).get('exportYN')=='Y'?true:false);
    store.getAt(i).set('deleteYN',store.getAt(i).get('deleteYN')=='Y'?true:false);
    store.getAt(i).set('viewYN',store.getAt(i).get('viewYN')=='Y'?true:false);
    }

    });
    }

    }


    function saveAndUpdate(){


    // alert(" i nsave and Update"+myIds.length);


    //alert(Ext.ComponentMgr.get(myIds[1]));


    for(var i=0;i<myIds.length;i++){

    var gridName=Ext.ComponentMgr.get(myIds[i]);

    // alert(" < < < <"+gridName.getStore().getCount());
    // alert(" < < < <"+RoleMenuLinksStore.getCount());
    var s=gridName.getSelectionModel().getSelection();

    //alert(i+" s lenthh "+s.length);


    if(s.length==0){

    //alert(" No records selected in "+myIds[i]+"");

    }else{

    var menuKey=s[i].get('menuKey');
    // alert(s[i].get('addYN')==true);

    var addYN=s[i].get('addYN')==true?'Y':'N';
    var editYN=s[i].get('editYN')==true?'Y':'N';
    var viewYN=s[i].get('viewYN')==true?'Y':'N';
    var deleteYN=s[i].get('deleteYN')==true?'Y':'N';
    var exportYN=s[i].get('exportYN')==true?'Y':'N';

    // alert(addYN+":"+editYN+":"+viewYN+":"+deleteYN+":"+exportYN);

    s[i].set('addYN',addYN);
    s[i].set('editYN',editYN);
    s[i].set('viewYN',viewYN);
    s[i].set('deleteYN',deleteYN);
    s[i].set('exportYN',exportYN);
    // alert('Hi1234');
    //alert("hi 111");
    //var record=Ext.create('RoleMenuLinks');

    //alert("hi ");
    // record.set({
    // menuKey:menuKey,
    // addYN:addYN,
    // editYN:editYN,
    // viewYN:viewYN,
    // deleteYN:deleteYN,
    // exportYN:exportYN
    //
    // });

    // gridName.getStore().update(record);
    gridName.getStore().sync();
    // alert(" 0 ");

    }

    }


    }

    But Its not calling java controller.....

    Attached Images

Thread Participants: 1

Tags for this Thread