PDA

View Full Version : [CLOSED] Probable bug into grid when row is selected and store is reloaded



pbaccari
14 Nov 2007, 1:40 PM
Hello,

I have a grid which open a form when a raow is selected (by doubleclick, or by clic on a button "modify").
The action open a layout with the form and i can modify the row in my database.
When i submit form :

data are modified in my database,
i reload my store,
i refresh my gridview.


The problem :

when i modify again the selected row (which is still selected), data on my form are the initial data (before the modification),
but if i select another row, and select again my initial row to modify, datas are ok in my form.


I think it's a problem of selection refresh when the store is reload (the selected row seems do problem).

I try by code to :

modify in my database,
reload my store
refresh my gridview
clear selection
select an another row
select my initial row
modify this row

But it does'nt work ...

Excuse me for my poor english, i hope this is clear.

Best regards.

brian.moeskau
18 Nov 2007, 11:56 PM
It sounds more likely that it's an issue in your code, not a bug, but if you can provide a test case showing the issue we'd be happy to take a look.

pbaccari
21 Nov 2007, 1:49 AM
It's a little difficult to send a test case, because form put data in database.
Would you a complete test cas, with database action (a zip with code + database), or just my page code ?

brian.moeskau
21 Nov 2007, 2:02 AM
You can always switch your store to use a small set of local array test data. A test case doesn't have to look or act like your application -- it only has to demonstrate the issue. Create a simple grid with a couple of rows and a simple form of one or two fields -- just enough to show the problem. Without some code to look at, there's really no way anyone can help you. Often the act of actually creating the test case also helps people realize something they are doing incorrectly, especially if the test case ends up working. ;)

craneleeon
21 Nov 2007, 11:50 PM
I occur this issue too.
My case is:
'When I dbClick a row will pop up a dialog box, then I do the 'Update' function by click a button, this function will submit a form and reload the DataStore to refresh the grid (seems it refresh the grid rows, I'm not sure about what really done by Extjs in this progress). After all these, when I hold the 'Ctrl' and click the selected row (which is just dbClicked and still appears selected) to unselect it, when I press another button to do the 'Delete' function, it seems the row still be selected. Is this issue can be fix? Please help me, Thx
below is my code


//--------Delete-----------------
var doDel = function(){
var m = grid.getSelections();
if(m.length > 0) {
Ext.MessageBox.confirm(lblMessage, DeleteConfirmMessage , doDel2);
}
else {
Ext.MessageBox.alert(lblError, At_Least_1_Select_To_Delete);
}
};

var doDel2 = function(btn){
if(btn == 'yes') {
Ext.get('fContent').mask(lblDeleting,'x-mask-loading');
var m = grid.getSelections();
var ids = '';
for(var i = 0, len = m.length; i < len; i++){
ids+=m[i].id+ID_SEPARATOR;
}
category = 'SEARCH_TYPE_ALL';
Ext.Ajax.request({
url:home_dir + '/transaction/TempMemberStSlipDetail.action',
method:'post',
params:{action:'DELETE',delDataIDs:ids},
failure: function(response, options) {
var repTx = Ext.util.JSON.decode(response.responseText);
Ext.MessageBox.alert(lblMessage, repTx.info);
},
success: function(action) {
ds.reload();
},
callback: function(options, success, response){
Ext.get('fContent').unmask();
}
});
}
};

// -------Update---------
grid.on('rowdblclick',function(grid, rowIndex, e){
Ext.get('fContent').mask(lblLoading,'x-mask-loading');
var m = grid.getSelections()[0];
var selectedId = m.id;
// get information from DB and set form now...
var object_data = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:home_dir + '/transaction/TempMemberStSlipDetail.action?action=LOAD&id=' + selectedId}),
reader : new Ext.data.XmlReader({
record: 'TempMemberStSlip',
id: 'id'
}, [
'busiDate',
{name:'slipNo',type:'int'},
'memberCode'
]),
remoteSort: false
});

var updateData = function(_st, _r, options){
if(_r.length < 1) return;
// set value now
//var updateId = member_data.getAt(0).data['id'];
busiDate_show.setValue(object_data.getAt(0).data['busiDate']);
slipNo_show.setValue(object_data.getAt(0).data['slipNo']);
memberCode_show.setValue(object_data.getAt(0).data['memberCode']);

var updateInstanceDlg;
if (!updateInstanceDlg) {
updateInstanceDlg = createNewDialog("a-updateInstance-dlg");
updateInstanceDlg.addButton(lblSave, function() {
// validation now

// submit now... all the form information are submit to the server
// handle response after that...
if (form_instance_update.isValid()) {
form_instance_update.submit({
waitMsg:lblUpdating,
reset: false,
success: function(form_instance_update, action) {
Ext.MessageBox.alert(lblMessage, action.result.info);
updateInstanceDlg.hide();
ds.reload();
}
});
}else{
Ext.MessageBox.alert(lblError, lblPlease_fix_error);
}
});

var layout = updateInstanceDlg.getLayout();
layout.add('center', new Ext.ContentPanel('a-updateInstance-inner', {title: 'center'}));

layout.layout();
updateInstanceDlg.show();
}
};

tryanDLS
22 Nov 2007, 9:00 AM
Are you calling selModel.clearSelections() anywhere?

craneleeon
22 Nov 2007, 4:51 PM
No I didn't call selModel.clearSelections() after or before ds.reload(), cause I just want the dbClicked row appears selected after reloaded, can't this be this way, can it:-/?

pbaccari
23 Nov 2007, 12:32 AM
Yes i put :
selModel.clearSelections()
before refresh the grid (datastore).

craneleeon
25 Nov 2007, 4:53 PM
It works Thx a lot.