When performing a dynamicForm.saveData (update) the listgrid that is bound to the same DS adds a listing instead of updating the existing record. Using SmartClient 6. Fairly sure this is my mistake and not a bug, but I’ve searched everywhere. Thanks for the assistance:
My dataSource:
// Nodes Grid DS
isc.DataSource.create({
ID:"node_list_ds",
autoFetchData:false,
fields:[
{name:"node_label",required:true},
{name:"company_id",required:true},
{name:"node_type",required:true},
{name:"node_street_1",required:true},
{name:"node_city",required:true},
{name:"node_state",required:true},
{name:"node_postal_code",required:true},
{name:"node_phone",required:true}
],
dataFormat:"xml",
recordXPath:"//node",
dataURL:"/index.php/?c=node",
transformRequest : function (dsRequest) {
var params = {
a : dsRequest.operationType
};
return isc.addProperties({}, dsRequest.data, params);
}
});
// Nodes Grid
isc.ListGrid.create({
ID: "node_list",
height:"30%",
alternateRecordStyles:true,
fields:[{name:"node_label",title:"Label"}],
dataSource: node_list_ds,
recordClick: function() {
node_detailviewer.setData(node_list.getSelectedRecord());
node_detail_tabs.selectTab(tab_node_view);
new_node_form.clearErrors(true);
node_form.clearErrors(true);
node_form.setData(node_list.getSelectedRecord());
},
autoFetchData: true
});
// Node Form
isc.DynamicForm.create({
ID:"node_form",
autoDraw:false,
height:"45%",
dataSource:node_list_ds,
autoFetchData: false,
saveOnEnter:true,
styleName:"node_form",
cellPadding:1,
titleWidth:80,
align:"left",
titleSuffix:' ',
requiredTitleSuffix:' ',
submit : function() {
node_form.saveData("node_detailviewer.setData(data);",{operationType:"update"});
},
fields:[
{name:"note", defaultValue:"Required fields are <b>bold</b>.", type:"header", cellStyle:"required_notice", width:"100%", height:15},
{name:"node_label", title:"Label", width:190},
{name:"company_id", title:"Company",
width:190,
type:"select"
},
{name:"node_type", title:"Type", type:"select", width:190, valueMap: {
"Publisher" : "Publisher",
"CMR" : "CMR"
}},
{name:"node_street_1", title:"Street 1", width:190},
{name:"node_street_2", title:"Street 2", width:190},
{name:"node_city", title:"City", width:190},
{name:"node_state", title:"State", width:190},
{name:"node_postal_code", title:"Postal Code", width:190},
{name:"node_phone", title:"Phone", width:190},
{name:"node_fax", title:"Fax", width:190},
{name:"savebtn", cellStyle:"node_update_cell", type:"submit", width:100, align:"center", colSpan:2, title:"Update"}
]
});
So basically what happens is when my node_form.saveData completes, a listing gets added to the bottom of my listGrid, creating a second listing (there are not 2 listings server side). The update call returns xml such as:
<Detail>
<node>
<node_id>48</node_id>
<node_label>1 OLD</node_label>
<company_id>5</company_id>
<node_type>Publisher</node_type>
<node_street_1>jJJJ</node_street_1>
<node_street_2>jsdf</node_street_2>
<node_city>j</node_city>
<node_state>jsdf</node_state>
<node_postal_code>j</node_postal_code>
<node_phone>j</node_phone>
<node_fax>sdfsdf</node_fax>
</node>
</Detail>
Thanks for any help!