1

我需要一个包含可以通过复选框选择的相关可用选项列表的表单。选项的数量可能非常大,每个表单记录都有自己的一组选项。选择的选项可能会在每次提交时更改。
我正在使用带有 php 服务器的 JSON 数据源,所以我只使用 SmartClient 客户端。
我已经使用了可用的示例来创建我的 canvasItem,但我有两个问题:
1. 当我在表单 dataSource 上 fetchData 时,canvasItem dataSource 不执行提取。
2.canvasItem的变化不包含在表单提交中。
这是我的测试代码:
dataSource Code。
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 浏览器。

4

1 回答 1

1

Q1.当我在表单数据源上 fetchData 时,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()));
},
于 2012-02-29T21:14:58.730 回答