1. #1
    Ext User
    Join Date
    Jan 2008
    Posts
    46
    Vote Rating
    0
    sathishs is on a distinguished road

      0  

    Default error in deleting row in gridpanel

    error in deleting row in gridpanel


    Hi,
    To delete a row in grid panel,I used grid.getSelections(),function.but firebug shows the error
    ->grid has no properties
    ->[Break on this error] var m = grid.getSelections();

    my code:js


    Ext.onReady(function() {

    var myData = [
    ['name1','author1'],
    ['name1','author2'],
    ['name1','author3'],
    ];

    var store1 = new Ext.data.SimpleStore({
    fields: [
    {name: 'author'},
    {name: 'title'},

    ]
    });
    function doDel(store,grid){
    var m = grid.getSelections();
    alert(m);
    if(m.length > 0)
    {
    Ext.MessageBox.confirm('Message', 'Do you really want to delete it?' , doDel2);
    }
    else
    {
    Ext.MessageBox.alert('Message', 'Please select at least one item to delete');
    }

    }

    function doDel2(btn)
    {
    if(btn == 'yes')
    {
    var m = grid.getSelections();
    var jsonData = "[";
    for(var i = 0, len = m.length; i < len; i++){
    var ss = "{\"id\":\"" + m[i].get("id") + "\"}";
    //alert(ss);
    if(i==0)
    jsonData = jsonData + ss ;
    else
    jsonData = jsonData + "," + ss;
    store.remove(m[i]);
    }
    jsonData = jsonData + "]";
    store.load({params:{start:0, limit:myPageSize, delData:jsonData}});
    }
    }



    store1.loadData(myData);

    var cm1 = new Ext.grid.ColumnModel([
    {header: "Author", width: 120, dataIndex: 'author'},
    {header: "Title", width: 180, dataIndex: 'title'},

    ]);
    cm1.defaultSortable = true;

    var grid1 = new Ext.grid.EditorGridPanel({
    store: store1,
    cm: cm1,
    id : 'test',
    viewConfig: {
    forceFit:true
    },
    buttons: [
    {
    text:'New',
    id:'new-vlan',


    },{

    text:'Delete',
    id:'delete-vlan',
    handler:doDel(),

    }],



    renderTo: 'example-grid',
    width:700,
    height:300,
    collapsible: true,
    style: 'padding:20px 0px 10px 200px',
    title:'test',
    autoScroll: true,
    monitorResize: true,
    frame:true
    });


    });
    I am unable to debug this error.If any one find wats the problem pls reply.
    Thx in advance
    sathishs

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Your doDel function expects parameters store and grid, but you are calling the function without parameters.

    Use:

    Code:
    handler:function() {
      doDel(grid1, store1);
    }

  3. #3
    Ext User
    Join Date
    Jan 2008
    Posts
    46
    Vote Rating
    0
    sathishs is on a distinguished road

      0  

    Default using getSelections()

    using getSelections()


    Hi,
    Thx for reply.After doing the above changes in my code,Now it shows grid.getSelections() is not a function.I checked API but I am not able to find this function.Is there any other functions to replace this one or shall I use the same function in different way?

    Regards,
    sathishs

  4. #4
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618
    Vote Rating
    1
    catacaustic is on a distinguished road

      0  

    Default


    What you need there is:
    Code:
    grid.getSelectionModel ().getSelctions ()
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

  5. #5
    Ext User
    Join Date
    Jan 2008
    Posts
    46
    Vote Rating
    0
    sathishs is on a distinguished road

      0  

    Default still showing err

    still showing err


    It shows the err,
    this.selModel.getSelections is not a function
    [Break on this error] return this.selModel.getSelections();

  6. #6
    Sencha User catacaustic's Avatar
    Join Date
    Jul 2007
    Location
    "A Land Down Under"
    Posts
    618
    Vote Rating
    1
    catacaustic is on a distinguished road

      0  

    Default


    Quote Originally Posted by sathishs View Post
    It shows the err,
    this.selModel.getSelections is not a function
    [Break on this error] return this.selModel.getSelections();
    Where are you getting selModel from? If it is actually a selection model object then it has that function. By the looks of it you're not getting the selection model right, so it can't do anything.
    'Once again, fortune vomits on my eiderdown'
    - Edmund Blackadder

  7. #7
    Ext User
    Join Date
    Jan 2008
    Posts
    46
    Vote Rating
    0
    sathishs is on a distinguished road

      0  

    Default working fine

    working fine


    Thanks alot

Thread Participants: 2