Hybrid View

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default Unanswered: Error delete multi selected items from list

    Unanswered: Error delete multi selected items from list


    Hi guys, like you can see, I want to delete multi selected items from my list but I can't get it, I have this:


    List:


    Code:
    var listaPlanFact = new Ext.List({
        id: 'listaPlanFact',
        store: planFactStore,
        multiSelect: true,
        simpleSelect: true,
        onItemDisclosure: function (record) {
            planFactPanelEditor.load(record);
            planFactPanelPrincipal.setActiveItem('planFactPanelEditor', { type: 'slide', direction: 'left' });
        },
        itemTpl: '<div>{FecFact}</div>' +
            '<div>{Denomi}</div>',
        listeners: {
            'render': function (thisComponent) {
                thisComponent.getStore().load();
            }
        }
    });

    Button:


    Code:
    {
            xtype: 'button',
            iconCls: 'trash',
            iconMask: true,
            handler: function () {
                var currentPlanFactCount = listaPlanFact.getSelectionCount();
                var currentPlanFact = listaPlanFact.getSelectedRecords();
                var planfactstore = listaPlanFact.getStore();
                for(var i=0;i<currentPlanFactCount;i++)
                {
                    if(planfactstore.findRecord('id', currentPlanFact[i].data.id)) {
                        planfactstore.remove(currentPlanFact[i]);
                    }
                    planfactstore.sync();
                }
                listaPlanFact.refresh();
            }
        }
    It works fine when I delete one item selected, but when I try to delete more of that, and reload the page, I get this error message:

    'Uncaught TypeError: Cannot read property 'id' of null'

    What can be? Please help me.
    Thanks very much for your time.

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    I was looking for a solution and I found this, but doesn't work for me.

    Code:
    {
    name : 'firstName', mapping : 'first name', type : 'string', convert : function(val) { if (!val) { val = ''; } return val; }
    }
    http://www.sencha.com/forum/showthre...ty-xxx-of-null

    Model:

    Code:
    Ext.regModel('planFactModel',{	idProperty: 'id',
        fields: [
    		{name: 'id', mapping : 'id', type: 'int', convert : function(val) { if (!val) { val = ''; } return val; }},
            {name: 'FecFact',  type: 'string'},
            {name: 'Denomi',  type: 'string'},
            {name: 'Porc', type: 'string'},
            {name: 'ValorFact', type: 'string'},
            {name: 'Moneda', type: 'string'},
            {name: 'Bloqueo', type: 'string'},
            {name: 'RGLFact', type: 'string'},
    		{name: 'Status', type: 'string'},
            {name: 'CPag', type: 'string'},
            {name: 'CatF', type: 'string'},
    		{name: 'CFact', type: 'string'},
            {name: 'NroHito', type: 'string'},
            {name: 'Fij', type: 'string'}
        ]
    });
    I don't know what to do.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    Any idea? Please ...

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    Can anybody help me please?

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
    izak18 is on a distinguished road

      0  

    Default


    Hi, I just saw that when I create the first record of the store, the ID creates twice , like you can see in the image (it is other store but happen the same thing):

    1.png

    Why is that?
    This is my code 'save':

    Code:
    text: 'Save',
    iconCls: 'organize',
    iconMask: true,
    ui: 'action',
    handler: function () {
    
    
        var currentPlanFact = planFactPanelEditor.getRecord();
        planFactPanelEditor.updateRecord(currentPlanFact);
    
        var planfactstore = listaPlanFact.getStore();
        if (null == planfactstore.findRecord('id', currentPlanFact.data.id)) {
            planfactstore.add(currentPlanFact);
        }
        planfactstore.sync();
        planFactPanelPrincipal.setActiveItem('planFactPanelLista', { type: 'slide', direction: 'right'});
    }
    Please help me.