我正在尝试使用批量删除创建一个网格,但我的后端(asp.NET WebApi)遇到了问题。
我设置了以下数据源:
var QueueMessages = {
transport: {
read: {
// omitted
},
destroy: {
url: "api/QueueMessages/deleteMessages",
dataType: "json",
type: "DELETE"
}
},
schema: {
// omitted
},
autoSync: false,
batch: true
};
以及 api 控制器的相关部分:
// batch version
[HttpDelete]
public HttpResponseMessage deleteMessages(IEnumerable<MessageHeader> headers)
{
foreach( MessageHeader header in headers )
{
try
{
// delete each...
}
catch (Exception e)
{
// handle exceptions...
}
}
return new HttpResponseMessage(HttpStatusCode.OK);
}
请求到达 deleteMessages,但headers
似乎为空
我猜它设置错误,但我无法弄清楚什么是错的..
编辑: 1. MessageHeader 类(如果想知道属性,则从 wcf 服务导入):
[DataContract]
public class MessageHeader
{
public MessageHeader(string id, string profileName, MessageQueueType queueType, DateTime acceptedAt, DateTime processedAt)
{
this.Id = id;
this.ProfileName = profileName;
this.QueueType = queueType;
this.AcceptedAt = acceptedAt;
this.ProcessedAt = processedAt;
}
[DataMember(Name="Id")]
public String Id { get; private set; }
[DataMember(Name="ProfileName")]
public String ProfileName { get; private set; }
[DataMember(Name = "QueueType")]
public MessageQueueType QueueType { get; private set; }
[DataMember(Name="AcceptedAt")]
public DateTime AcceptedAt { get; private set; }
[DataMember(Name="ProcessedAt")]
public DateTime ProcessedAt { get; private set; }
}
2. 对服务器的请求看起来像(来自 chrome devtools):
models[0][AcceptedAt]:Thu Sep 04 2014 17:48:44 GMT+0300 (Jerusalem Daylight Time)
models[0][Id]:3c42c940-6711-4107-b02f-0e6842e1f771\424231
models[0][ProcessedAt]:Mon Jan 01 1 00:00:00 GMT+0200 (Jerusalem Standard Time)
models[0][ProfileName]:V11_DEV
models[0][QueueType]:0