我需要一个表单,其中包含可通过Checkbox选择的相关可用选项列表。选项的数量可能非常大,每个表单记录都有自己的一组选项。所选的选项可能会在每次提交时更改
我正在使用带有php服务器的JSON dataSources,所以我只使用SmartClient客户端
我使用了可用的示例来创建我的canvasItem,但我有两个问题:
1.当我在表单dataSource上获取数据时,canvasItem数据源不会进行提取
2. canvasItem中的更改不包含在提交表单中
这是我的测试代码:
dataSource代码。
isc.DataSource.create({
ID:"PointDetlData",dataFormat:"json",idField: "NodeId",
fields:[{name:"NodeId",primaryKey:true,type:"integer",title:"Node Id"},
{name:"RowId",title:"Row",canEdit:"false"},
{name:"Code",title:"Product",canEdit:"false"},
{name:"Name",title:"Details",canEdit:"false"},
{name:"Sel",type:"boolean",title:"Assign"}],
operationBindings:[{operationType:"fetch", dataURL:"dsdet.json"},
{operationType:"update",dataURL:"updateTestDetail.php"}]
});
isc.DataSource.create({
ID:"PointData",dataFormat:"json",idField: "NodeId",
fields:[{name:"NodeId",primaryKey:true,type:"integer",title:"Node Id"},
{name:"PointId",type:"integer",title:"PointId"},
{name:"CompanyNodeID",title:"Company"},
{name:"Level",title:"Node Type"},
{name:"Name",title:"Name"},
{name:"items[]",title:"Order Items",multiple:"true",type:"PointDetlData"}],
operationBindings:[{operationType:"fetch", dataURL:"ds.json"},
{operationType:"update",dataURL:"updateTest.php"}]
});
canvasItem定义
isc.ClassFactory.defineClass("GridEditorItem", "CanvasItem");
isc.GridEditorItem.addProperties({
height:"*", width:"*",
rowSpan:"*", endRow:true, startRow:true,
shouldSaveValue:true,
createCanvas : function () {
return isc.ListGrid.create({
autoDraw:false,
ID:"exampleFormGrid",
width:this.width, height:this.height,
leaveScrollbarGaps:false,
dataSource:this.gridDataSource,
fields:this.gridFields,canEdit:true,modalEditing:true,
saveLocally:true,autoSaveEdits:false,
cellChanged : function () {
this.canvasItem.saveValue(this.data);
if (this.canvasItem.gridSortField != null)
{this.sort(this.canvasItem.gridSortField);}
},
dataArrived : function () {this.canvasItem.showValue(null, this.canvasItem.getValue());},
selectionUpdated : function (record) {
var item = this.canvasItem;
if (record == null) item.storeValue(null);
else item.storeValue(record[item.name]);
},
refreshData : function (filter) {if (typeOf(filter) != null) this.fetchData(filter);}
});
},
showValue : function (displayValue, dataValue) {
if (this.canvas == null) return;
var record = this.canvas.data.find(this.name, dataValue);
if (record) this.canvas.selection.selectSingle(record)
else this.canvas.selection.deselectAll();
}
});
dynamicForm代码。
isc.DynamicForm.create({
ID: "exampleForm", autoDraw:true,
width: 700, height: 350, position:"relative",
dataSource:"PointData",
fields: [{name:"NodeId" },
{name:"PointId" },
{name:"items[]",
width:350,
colSpan:2,showTitle:false,
editorType:"GridEditorItem",
gridDataSource:"PointDetlData",
gridFields:[{name:"RowId"},{name:"Code"},{name:"Name"},{name:"Sel"}],
gridSortField:"RowId"},
{name:"Level"},{name:"Name"},
{editorType:"SubmitItem", title:"Save"}]
});
exampleForm.fetchData({NodeId:4});
我正在使用SmartClient 8.1 / LGPL部署(内置2011-08-02)和Firefox 8.0浏览器。
答案 0 :(得分:1)
Q1。当我在表单dataSource上获取数据时,canvasItem数据源不会进行提取。
如果使用服务器端SmartClient,则加入两个数据源,以便刷新两个数据源,否则必须执行手动提取。
Q2。 canvasItem中的更改不包含在提交表单中。
使用以下内容替换当前isc.GridEditorItem.addProperties中的函数:
selectionUpdateTest : function (iRowId,sStoreArray) {
var outArray = new Array();
var bFound = false;
if (sStoreArray ==undefined) { bFound = false;}
else {
for (var i = 0;i <sStoreArray.length;i++) {
if (sStoreArray[i] == iRowId)
bFound = true;
else
outArray[outArray.length] = sStoreArray[i];
}
}
if (!bFound)
outArray[outArray.length] = iRowId;
return outArray;
},
selectionUpdated : function (record) {
var item = this.canvasItem;
if (record == null)
item.storeValue(null);
else
item.storeValue(this.selectionUpdateTest(record.RowId,item.getValue()));
},