yehezqiel
13 Sep 2010, 6:56 PM
please somebody help me..
how to change url of data store when a button was clicked..
my code for the grid is like this :
Ext.onReady
(
function()
{
Ext.QuickTips.init();
var ds_model = Ext.data.Record.create
([
'no',
'message',
'status'
]);
var store = new Ext.data.Store
({
url: 'doData?no=1',
reader: new Ext.data.JsonReader
(
{
root:'rows',
id: 'no'
},
[
'no',
'message',
'status'
]
)
});
store.load();
var grid = new Ext.grid.EditorGridPanel
({
renderTo: 'editor-grid',
frame:true,
title: '<div align="center">Message Detail</div>',
height:500,
width:900,
autoWidth:true,
store: store,
clickstoEdit: 1,
columns:
[
{header: "No.", dataIndex: 'no', width:70},
{header: "Message", dataIndex: 'message', sortable:true, autoWidth:true, width: 700},
{header: "Status", dataIndex: 'status', sortable:true, autoWidth:true, width:100}
]
});
}
that's only show 1 row in the grid.
and then i want if the user click the button, then the grid should show all records in the database..
so i must change the url of data store, but i can't find how to do it..
function addRow()
{
grid.getStore().url = 'doData'; // it doesn't work
grid.getStore().load(); // the store was loaded with first url defined when create data store
}
var btnAdd = new Ext.Button
({
applyTo: 'btnAdd',
text: 'Add Row'
}) ;
btnAdd.addListener('click',addRow);
thx b4..
how to change url of data store when a button was clicked..
my code for the grid is like this :
Ext.onReady
(
function()
{
Ext.QuickTips.init();
var ds_model = Ext.data.Record.create
([
'no',
'message',
'status'
]);
var store = new Ext.data.Store
({
url: 'doData?no=1',
reader: new Ext.data.JsonReader
(
{
root:'rows',
id: 'no'
},
[
'no',
'message',
'status'
]
)
});
store.load();
var grid = new Ext.grid.EditorGridPanel
({
renderTo: 'editor-grid',
frame:true,
title: '<div align="center">Message Detail</div>',
height:500,
width:900,
autoWidth:true,
store: store,
clickstoEdit: 1,
columns:
[
{header: "No.", dataIndex: 'no', width:70},
{header: "Message", dataIndex: 'message', sortable:true, autoWidth:true, width: 700},
{header: "Status", dataIndex: 'status', sortable:true, autoWidth:true, width:100}
]
});
}
that's only show 1 row in the grid.
and then i want if the user click the button, then the grid should show all records in the database..
so i must change the url of data store, but i can't find how to do it..
function addRow()
{
grid.getStore().url = 'doData'; // it doesn't work
grid.getStore().load(); // the store was loaded with first url defined when create data store
}
var btnAdd = new Ext.Button
({
applyTo: 'btnAdd',
text: 'Add Row'
}) ;
btnAdd.addListener('click',addRow);
thx b4..