在KendoUI数据源中获取更新请求的字符串
Getting a string on an update request in KendoUI datasource
我有一个非常简单的网格,数据源可以正确检索数据因为我有一个图式。解析函数定义
问题是,当我尝试更新/创建新行schema.parse()再次调用和传递给它的参数是一个字符串,包含我的页面的HTML。真搞不懂这到底是怎么回事。由于
var _dataSource = new kendo.data.DataSource({
transport: {
read: {
dataType: "json",
url: layerDefProvider.getLayerUrlById("surveys") + "/query",
data: {
f: "json",
//token: token,
outFields: "*",
//outSR: 3857,
where: "1=1"
},
type: "POST"
},
create: function (options) {
console.debug("called");//never gets called
},
update: function (options) {
console.debug("called");//never gets called
},
destroy: function (options) {
console.debug("called");//never gets called
}
},
filter: {
field: "OBJECTID", operator: "eq", value: 0
},
schema: {
data:function(response) {
},
parse: function (data) {//on loading it is fine, on updating the data param is a string of my HTML of the page
var rows = [];
var features = data.features;
if (!features) {
return [];
}
for (var i = 0; i < features.length; i++) {
var dataRow = {};
dataRow.OBJECTID = features[i].attributes.OBJECTID;
dataRow.Name = features[i].attributes.Name;
dataRow.Date = features[i].attributes.Date;
dataRow.Comment = features[i].attributes.Comment;
rows.push(dataRow);
}
return rows;
},
model: {
id: "OBJECTID",
fields: {
OBJECTID: { type: "number", editable: false },
Name: { type: "string" },
Date: { type: "string" },
Comment: { type: "string" }
}
}
}
});
var _surveysPicker = $(config.table).kendoGrid({
toolbar: ["create","save"],
editable: true,
dataSource: _dataSource,
height: 300,
sortable: true,
selectable: "multiple",
columnMenu: true,
resizable: true,
columns: [{
field: "OBJECTID",
width: 40
}, {
field: "Name",
width: 40
}, {
field: "Date",
width: 40
}, {
field: "Comment",
width: 100
}]
});
如果您只需要在read操作中解析数据,则需要将解析函数移动到read事件中。
相关文章:
- Ajax请求返回空的数据字符串,但首先得到了正确的数据
- Javascript/jQuery/AAJAX-从网站请求字符串
- 将GET请求(HTML字符串)转换为完整的DOM对象
- 从输入中获取字符串,并在AngularJS中发出AJAX请求
- 通过字符串请求方法
- jQuery ajax请求,将索引数组作为关键字字符串
- @RequestParam不接受'&'在从请求发送的字符串中,存储&并截断其余部分
- 如何在JavaScript中将JSP请求属性转换为字符串并将其分配给对象
- 当用户在命令提示符中选择任何字符串时,节点Js不为任何请求提供服务
- 为什么我的 http 请求不适用于长 JSON 字符串
- node.js请求POST数组“;第一个参数必须是字符串或缓冲区;
- AngularJS$http POST请求,带有JSON参数AND查询字符串
- 通过javascript获取原始/未修改的请求字符串
- 使用javascript动态处理请求字符串
- 如何从请求字符串的参数值中提取相对URL
- 如何从ajax post请求的请求字符串中获取参数
- 如何请求字符串,然后将其用作数组的一部分
- 如何将json对象添加到请求字符串
- 解析GET请求字符串为HTML
- 在请求字符串中发送印地语字符时获取垃圾值