PDA

View Full Version : How to refresh a grid



sarsipius
25 Nov 2008, 6:21 AM
Hi,

I try to refresh a grid but it doesn't work

I use this code with GXT 1.1.4:



grid.getView().refresh(false);


Can someone help me?

fother
25 Nov 2008, 7:03 AM
grid.getStore().getLoader().load()

why you need refresh?

sarsipius
25 Nov 2008, 7:08 AM
thanks you for your reply

I think I don't proceed in the right way

The grid is a view of a database table and I would like to refresh the grid when I commit the change in the grid (followed by an update in the database) in order to provide the last data

I think it would be better if I used BeanModelGrid...

Does it seem more efficient?

fother
25 Nov 2008, 7:11 AM
use this grid.getStore().commitChanges();

you will called this method only if your database update return success..

sarsipius
25 Nov 2008, 7:18 AM
1) edit the grid
2) click the "save" button
3) update the database
4) if the update is successful, call your method to refresh the grid

Am I right?

fother
25 Nov 2008, 7:24 AM
yes

example


TextToolItem salva = new TextToolItem(App.MESSAGES.salvar(), CSS.Style.ICON_SAVE.getStyle());
salva.addSelectionListener(new SelectionListener<ToolBarEvent>() {

@Override
public void componentSelected(ToolBarEvent ce) {

List<Record> record = grid.getStore().getModifiedRecords();

if (record.size() > 0) {

List<Entity> otherEntityList = new ArrayList<Entity>();

OtherEntity otherEntity = null;

for (Record rec : record) {

otherEntity = new OtherEntity();
otherEntity.setValue((String) rec.get("value"));

otherEntityList.add(otherEntity);
}

// RemoteService
_service.save(otherEntityList, new AsyncCallback<OtherEntity>() {

public void onFailure(Throwable caught) {
System.out.println("Error");
}

public void onSuccess(OtherEntity result) {

grid.getStore().commitChanges();

System.out.println("Sucess");
}
});
}
}
});

sarsipius
25 Nov 2008, 7:26 AM
thanks a lot

getindas
25 May 2009, 6:42 AM
I have two grid panel. Transferring data from one panel to other.
I have a grid panel and adding data into the store using json using Ext.data.Store.

My problem is
there is one sort button. When i click on the sort button.

var selectedBool=false;
function selSortHandeler(){

if(selectedBool){
Ext.getCmp('selSortBtn').setIconClass('iw-sort-asc-icon');
selectedBool=false;
Ext.getCmp('selectedTagGrid').getStore().sort('label', 'ASC');
}
else{
Ext.getCmp('selSortBtn').setIconClass('iw-sort-desc-icon');
selectedBool=true;
Ext.getCmp('selectedTagGrid').getStore().sort('label', 'DESC');
}
}

data is coming in ascending or descending order. But some part of the data are hidden.

Like data is "EXT-JS"
after click on sort button. It is coming like .. "T-JS". Hide from left side.

Please, provide me solution. Data is sorted but not coming properly in grid.


Thanks in Advance.