I'm using: SmartClient_v110p_2017-05-15_PowerEdition
I have a 3 pane application with the typical tree in pane 1 and listgrid in pane 2. Selecting a record in the listgrid causes various details to become visible in the several detail tabs of pane 3. So far this works fairly well, however today I discovered a situation where saving a value in one of the detail panes to the table associated with the listgrid in pane 2 causes that grid to appear empty "No items to show" is displayed. To complicate matters the pane 2 listgrid datasource is bound to an SQL view that merges 6 tables. The detail pane form that makes the change uses another datasource bound to one of the undelying tables of the view.
I tried adding code to refresh the grid and reselect the record after the save operation, but that fails because the reselect fires before the refresh completes and get's ignored by the grid.
Am I missing some clean builtin functionality to refresh the listgrid and keep the selection after the save?
Or
Is there a way to get the selectSingleRecord call to wait until after the refresh has completed?
The listGrid:
isc.ListGrid.create({
ID:"peopleListGrid",
autoDraw:false,
autoFetchData:true,
dataSource:"peopleGrid", //This datasource is a view that connects the people table to 5 related tables to facilitate searching
reselectOnUpdate:true,
initialCriteria:{
fieldName:"active",
operator:"equals",
value:1.0
},
fields:[
...Omitting lots of fields here..
],
showFilterEditor:true,
sortDirection:true,
canGroupBy:true,
recordClick: {
target:"peopleDetailTabs",
name:"updateDetails"
},
selectionUpdated: {
target:"peopleDetailTabs",
name:"updateDetails"
},
filterEditorSubmit: {
target:"peopleDetailTabs",
name:"clearDetails"
}
})
The form:
isc.DynamicForm.create({
ID:"copierBaseCode",
autoDraw:false,
dataSource:"people", //This is a simple one table datasource
fields:[
{
name:"personalCode",
title:"Base Code",
_constructor:"TextItem"
}
],
// This function is called by clicking a button.
getCode: function () {
// Retrieve the person's personalCode or generate a new, unique, random one if it doesn't exist
var record = peopleListGrid.getSelectedRecord();
if(record == null) return null;
if(/[0-9]{4}/.test(record.personalCode)) {
myCode = record.personalCode;
} else {
myCode = Math.floor(Math.random()*(9999-1000))+1000;
while (peopleListGrid.fetchData({personalCode:myCode}) != null) {
myCode = Math.floor(Math.random()*(9999-1000))+1000;
}
this.editRecord({id_People:record.id_People,personalCode:myCode});
this.saveData();
// I thought the following 2 function calls would redraw the grid and reselect the person, but the selectSingleRecord() call get's ignored by the grid during refresh.
//topToolStripFilterForm.findPeople();
//peopleListGrid.selectSingleRecord({id_People:record.id_People});
}
return myCode;
}
})
I have a 3 pane application with the typical tree in pane 1 and listgrid in pane 2. Selecting a record in the listgrid causes various details to become visible in the several detail tabs of pane 3. So far this works fairly well, however today I discovered a situation where saving a value in one of the detail panes to the table associated with the listgrid in pane 2 causes that grid to appear empty "No items to show" is displayed. To complicate matters the pane 2 listgrid datasource is bound to an SQL view that merges 6 tables. The detail pane form that makes the change uses another datasource bound to one of the undelying tables of the view.
I tried adding code to refresh the grid and reselect the record after the save operation, but that fails because the reselect fires before the refresh completes and get's ignored by the grid.
Am I missing some clean builtin functionality to refresh the listgrid and keep the selection after the save?
Or
Is there a way to get the selectSingleRecord call to wait until after the refresh has completed?
The listGrid:
isc.ListGrid.create({
ID:"peopleListGrid",
autoDraw:false,
autoFetchData:true,
dataSource:"peopleGrid", //This datasource is a view that connects the people table to 5 related tables to facilitate searching
reselectOnUpdate:true,
initialCriteria:{
fieldName:"active",
operator:"equals",
value:1.0
},
fields:[
...Omitting lots of fields here..
],
showFilterEditor:true,
sortDirection:true,
canGroupBy:true,
recordClick: {
target:"peopleDetailTabs",
name:"updateDetails"
},
selectionUpdated: {
target:"peopleDetailTabs",
name:"updateDetails"
},
filterEditorSubmit: {
target:"peopleDetailTabs",
name:"clearDetails"
}
})
The form:
isc.DynamicForm.create({
ID:"copierBaseCode",
autoDraw:false,
dataSource:"people", //This is a simple one table datasource
fields:[
{
name:"personalCode",
title:"Base Code",
_constructor:"TextItem"
}
],
// This function is called by clicking a button.
getCode: function () {
// Retrieve the person's personalCode or generate a new, unique, random one if it doesn't exist
var record = peopleListGrid.getSelectedRecord();
if(record == null) return null;
if(/[0-9]{4}/.test(record.personalCode)) {
myCode = record.personalCode;
} else {
myCode = Math.floor(Math.random()*(9999-1000))+1000;
while (peopleListGrid.fetchData({personalCode:myCode}) != null) {
myCode = Math.floor(Math.random()*(9999-1000))+1000;
}
this.editRecord({id_People:record.id_People,personalCode:myCode});
this.saveData();
// I thought the following 2 function calls would redraw the grid and reselect the person, but the selectSingleRecord() call get's ignored by the grid during refresh.
//topToolStripFilterForm.findPeople();
//peopleListGrid.selectSingleRecord({id_People:record.id_People});
}
return myCode;
}
})
Comment