My listGrid comboBoxItem struggle continues.
I have a 2 column SQL table(spaceAssignments) that consists of foreign keys id_People and id_Rooms. The table serves to assign each person in the people table to 0 or more rooms in the rooms table. I have a listGrid that displays a person's assigned rooms by building name(pulled from the related building table) and room number. When I double click a record in the grid I can change the building and roomNumber, which is enough information to generate a new value for id_Rooms. When I press enter on my changed row I would like to run an SQL statement like:
update spaceAssignments set id_People=<current person>, id_Rooms=<new room> where id_People=<current person> and id_Rooms=<current room>;
Which would have the effect of assigning the person to a different room.
This does not seem to be what my current code is doing. So my question is can I add something to my listGrid/comboBox/datasource code to get the desired behavior? Should I write a datasource.transformRequest() function? Pursue some other solution like over-riding the save behavior of the grid?
When I hit enter to save changes to an edited record in the grid I get this in the server log:
=== 2017-06-08 15:32:01,051 [ec-8] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36': Safari with Accept-Encoding header
=== 2017-06-08 15:32:01,054 [ec-8] DEBUG XML - Parsed XML from (in memory stream): 2ms
=== 2017-06-08 15:32:01,055 [ec-8] DEBUG RPCManager - Processing 1 requests.
=== 2017-06-08 15:32:01,056 [ec-8] DEBUG RPCManager - Request #1 (DSRequest) payload: {
criteria:{
id_People:12331,
id_Rooms:10204
},
values:{
id_People:12331,
id_Rooms:10204,
code_Buildings:"0047",
buildingNameShort:"Chem",
roomNumber:"8333"
},
operationConfig:{
dataSource:"roomAssignments",
repo:null,
operationType:"update",
textMatchStyle:"exact"
},
componentId:"ListGrid3",
appID:"builtinApplication",
operation:"roomAssignments_update",
oldValues:{
roomTypeFull:"Lab-Instruction",
code_Buildings:"0408",
roomNumber:"B41",
buildingNotes:"",
roomNotes:"",
id_Rooms:10009,
roomProgram:"Instr",
buildingNameLong:"Engineering Hall",
id_People:12331,
buildingNameShort:"Engr Hall",
roomDescription:"Remodeling in progress - Instruction",
occupantCapacity:0,
buildingNameAbbreviated:"EH",
roomSubtype:"Wet",
roomAreaSqFt:795
}
}
Both the criteria and the values in the DSRequest have id_Rooms=<new room id>. Should the criteria have id_Rooms=<old room id> ?
The listGrid code:
isc.ListGrid.create({
ID:"ListGrid3",
autoDraw:false,
autoFetchData:true,
canEdit:true,
dataSource:"roomAssignments",
fields:[
{
name:"id_People"
},
{
name:"code_Buildings",
canEdit:true,
title:"Building",
width:80,
displayField:"buildingNameShort",
valueField:"code_Buildings",
editorType:"ComboBoxItem",
editorProperties : {
optionDataSource:"buildings"
}
},
{
name:"id_Rooms",
title:"Room #",
width:70,
editorType:"ComboBoxItem",
displayField:"roomNumber",
valueField:"id_Rooms",
canEdit:true,
editorProperties:{
optionDataSource:"rooms",
displayField:"roomNumber",
valueField:"id_Rooms",
getPickListFilterCriteria : function () {
var selectedBuilding = this.grid.getEditedRecord(this.rowNum);
console.log("building",selectedBuilding);
return {
code_Buildings:selectedBuilding.code_Buildings
};
}
}
}
]
})
I have a 2 column SQL table(spaceAssignments) that consists of foreign keys id_People and id_Rooms. The table serves to assign each person in the people table to 0 or more rooms in the rooms table. I have a listGrid that displays a person's assigned rooms by building name(pulled from the related building table) and room number. When I double click a record in the grid I can change the building and roomNumber, which is enough information to generate a new value for id_Rooms. When I press enter on my changed row I would like to run an SQL statement like:
update spaceAssignments set id_People=<current person>, id_Rooms=<new room> where id_People=<current person> and id_Rooms=<current room>;
Which would have the effect of assigning the person to a different room.
This does not seem to be what my current code is doing. So my question is can I add something to my listGrid/comboBox/datasource code to get the desired behavior? Should I write a datasource.transformRequest() function? Pursue some other solution like over-riding the save behavior of the grid?
When I hit enter to save changes to an edited record in the grid I get this in the server log:
=== 2017-06-08 15:32:01,051 [ec-8] INFO RequestContext - URL: '/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36': Safari with Accept-Encoding header
=== 2017-06-08 15:32:01,054 [ec-8] DEBUG XML - Parsed XML from (in memory stream): 2ms
=== 2017-06-08 15:32:01,055 [ec-8] DEBUG RPCManager - Processing 1 requests.
=== 2017-06-08 15:32:01,056 [ec-8] DEBUG RPCManager - Request #1 (DSRequest) payload: {
criteria:{
id_People:12331,
id_Rooms:10204
},
values:{
id_People:12331,
id_Rooms:10204,
code_Buildings:"0047",
buildingNameShort:"Chem",
roomNumber:"8333"
},
operationConfig:{
dataSource:"roomAssignments",
repo:null,
operationType:"update",
textMatchStyle:"exact"
},
componentId:"ListGrid3",
appID:"builtinApplication",
operation:"roomAssignments_update",
oldValues:{
roomTypeFull:"Lab-Instruction",
code_Buildings:"0408",
roomNumber:"B41",
buildingNotes:"",
roomNotes:"",
id_Rooms:10009,
roomProgram:"Instr",
buildingNameLong:"Engineering Hall",
id_People:12331,
buildingNameShort:"Engr Hall",
roomDescription:"Remodeling in progress - Instruction",
occupantCapacity:0,
buildingNameAbbreviated:"EH",
roomSubtype:"Wet",
roomAreaSqFt:795
}
}
Both the criteria and the values in the DSRequest have id_Rooms=<new room id>. Should the criteria have id_Rooms=<old room id> ?
The listGrid code:
isc.ListGrid.create({
ID:"ListGrid3",
autoDraw:false,
autoFetchData:true,
canEdit:true,
dataSource:"roomAssignments",
fields:[
{
name:"id_People"
},
{
name:"code_Buildings",
canEdit:true,
title:"Building",
width:80,
displayField:"buildingNameShort",
valueField:"code_Buildings",
editorType:"ComboBoxItem",
editorProperties : {
optionDataSource:"buildings"
}
},
{
name:"id_Rooms",
title:"Room #",
width:70,
editorType:"ComboBoxItem",
displayField:"roomNumber",
valueField:"id_Rooms",
canEdit:true,
editorProperties:{
optionDataSource:"rooms",
displayField:"roomNumber",
valueField:"id_Rooms",
getPickListFilterCriteria : function () {
var selectedBuilding = this.grid.getEditedRecord(this.rowNum);
console.log("building",selectedBuilding);
return {
code_Buildings:selectedBuilding.code_Buildings
};
}
}
}
]
})
Comment