我想使用LGPL版本的智能客户端连接到我自己的服务器。我希望SmartClient发送一个获取请求(具有操作类型,范围等) - 我将处理其余的。但我不能强迫SmartClient这样做。我设法做的就是强迫它发送一个简单的GET请求。我应该添加什么?
我的代码:
<HTML>
<HEAD>
<SCRIPT>var isomorphicDir="../isomorphic/";</SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Core.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Containers.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Grids.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Forms.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
<SCRIPT SRC=../isomorphic/skins/SmartClient/load_skin.js></SCRIPT>
</HEAD>
<BODY>
<SCRIPT>
isc.DataSource.create({
ID:"countries",
dataURL:"countries_small.js",
fields:[
{name:"name", type:"text", primaryKey:true},
{name:"population"},
]
});
isc.ListGrid.create({
width: "100%",
height: 50,
dataSource: "countries",
drawAllMaxCells:0,
dataPageSize:1,
drawAheadRatio:1,
showAllRecords:false,
autoFetchData: true
});
</SCRIPT>
</BODY>
</HTML>
答案 0 :(得分:2)
isc.RestDataSource.create({
ID:"countriesDS",
dataFormat:"json",
dataURL: "partial.js",
operationBindings:[
{operationType:"fetch", dataProtocol:"postParams"}
],
fields:[
{title:"Name", name:"name", type:"text", primaryKey:true},
{title:"Population", name:"population", type:"text"}
]
});
isc.ListGrid.create({
width: "100%",
height: 60,
dataFetchMode:"paged",
dataSource: "countriesDS",
dataPageSize:2,
canEdit:true,
drawAheadRatio:1,
showAllRecords:false,
autoFetchData: true
});
然后,响应可能如下:
{ response:{
status:0,
startRow:0,
endRow:1,
totalRows:2,
data:[
{name:"Italy", population:"12"},
{name:"Germany", population:"121"}
]
}
}
答案 1 :(得分:0)
您要做的是为其他操作定义您的网址:
使用单独的绑定替换dataSource对象中的dataURL:
operationBindings:[
{operationType:"fetch", dataURL:"<fetch URL>"},
{operationType:"add",dataProtocol:"postParams", dataURL:"<insert URL>"},
{operationType:"update",dataProtocol:"postParams", dataURL:"<Update URL>"},
{operationType:"remove",dataProtocol:"postParams", dataURL:"<delete URL>"}]
设置网格ID并使其可编辑:
ID:"MyGrid"
canEdit: true,
editEvent: "click"
当您离开行时,它应该触发更新请求。
使用以下命令为新行和删除行添加按钮:
isc.IButton.create({title:"New",click:"MyGrid.startEditingNew()"});
isc.IButton.create({title:"Delete",click:"MyGrid.removeData()"});
离开行后,您的添加网址会收到请求。按下按钮后删除。
我希望这有用。