-
4 Feb 2008 2:37 AM #1
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
-
4 Feb 2008 4:21 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 43
Your doDel function expects parameters store and grid, but you are calling the function without parameters.
Use:
Code:handler:function() { doDel(grid1, store1); }
-
4 Feb 2008 7:43 PM #3
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 Feb 2008 9:50 PM #4
What you need there is:
Code:grid.getSelectionModel ().getSelctions ()
'Once again, fortune vomits on my eiderdown'
- Edmund Blackadder
-
4 Feb 2008 11:26 PM #5
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();
-
5 Feb 2008 2:09 PM #6
-
6 Feb 2008 2:37 AM #7


Reply With Quote