阿贾克斯阅读.如果 Model.customerId 的值为十进制,则不调用操作



我正在使用Telerik UI ASP.Net MVC Grid标签栏。我有两个标签。问题是,如果 model.customerId 的值为十进制,那么它不会调用像 (.读取(读取 => 读取。Action("UserVouchers_Read", "Admin", new { customerId = "#=CustomerId#" }(((

因此,如果 customerId 为"123456",则调用控制器操作"UserVouchers_Read"。

如果 customerId 为"123456.123",则不会调用控制器操作"UserVouchers_Read"。

下面是我在视图中的代码。请在这里建议可能出现的问题。

@(Html.Kendo().Grid<BSD.VoucherRedemption.Model.UserDataVM>()
.Name("Users")
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("Users_Read", "Admin"))
.Events(events => events.Error("onError"))
)
.Columns(columns =>
{
columns.Bound(userData => userData.UserDataId).Visible(false);
columns.Bound(userData => userData.CustomerId).Title("Client ID");
columns.Bound(userData => userData.FirstName);
columns.Bound(userData => userData.CreatedDate).Title("Created Date");
})
.Pageable(pager => pager.Input(true).PageSizes(true))
.Sortable()
.Scrollable()
.Filterable()
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:700px;" })
)
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().TabStrip()
.Name("tabStrip_#=CustomerId#")
.SelectedIndex(0)
.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
.Items(items =>
{
items.Add().Text("Voucher Information").Content(@<text>
@(Html.Kendo().Grid<BSD.VoucherRedemption.Model.UserVoucherVM>()
.Name("voucher_#=CustomerId#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Bound(v => v.UserVoucherId).Width(90).Title("Voucher ID").Filterable(false);
columns.Bound(v => v.VoucherNo);
columns.Bound(v => v.VoucherValue).Visible(false);
columns.Bound(v => v.IsVoucherRedeemedStr).Title("Is Voucher Redeemed");
columns.Bound(v => v.CreatedDate).Title("Assigned Date");
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.ServerOperation(false)
.Read(read => read.Action("UserVouchers_Read", "Admin", new { customerId = "#=CustomerId#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate())
</text>
);
items.Add().Text("Email Activity").Content(@<text>
@(Html.Kendo().Grid<BSD.VoucherRedemption.Model.UserVoucherVM>()
.Name("email_#=CustomerId#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Bound(v => v.UserVoucherId).Width(50).Title("Email ID").Filterable(false);
columns.Bound(v => v.CreatedDate).Width(50).Title("Email Sent Date");
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.ServerOperation(false)
.Read(read => read.Action("UserEmails_Read", "Admin", new { customerId = "#=CustomerId#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate())
</text>
);
})
.ToClientTemplate())
</script>

我建议您在发送十进制值时需要字符串化客户 ID 的值。

data: JSON.stringify({ CustomerId="#customerId" })

这是因为默认绑定器将小数视为整数。

最新更新