【发布时间】:2018-07-25 07:09:24
【问题描述】:
我正在使用 kendo ui 在我的项目中创建一个网格。我的问题是我无法将十进制值传递给我的 c# 类模型。
我的班级:
public class BlocCoefficientSettings
{
public int BlocCoefficientKey { get; set; }
public string BlocName { get; set; }
public string Category { get; set; }
public string MinMaxFloor { get; set; }
public int Rooms { get; set; }
public decimal CoefficientValue { get; set; }
public int GroupNumber { get; set; }
}
这是我渲染网格的代码
@section Scripts{
<script>
function grid_init() {
var dataSearch = {
classifierSearchKey: document.getElementById('classifierSearchKey').value
}
if (!dataSearch.classifierSearchKey == "") {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/BlocCoefficientsSettings?handler=Json",
dataType: "json",
data: dataSearch
},
update: {
url: "/Common/UpdateBlocCoefficientsSettings",
type: "POST",
dataType: "json"
}
},
batch: true,
sort: [{ field: "groupNumber", dir: "asc" }, { field: "rooms", dir: "asc" }],
schema: {
data: "results",
total: "total",
model: {
id: "blocCoefficientKey",
fields: {
blocName: { editable: false },
rooms: { editable: false, type: "number" },
minMaxFloor: { editable: false },
coefficientValue: { editable: true, type: "number", nullable: true }
}
},
},
page: 1,
serverPaging: false,
group: { field: "category" }
});
$("#grid").empty();
$("#grid").kendoGrid({
dataSource: dataSource,
editable: true,
height: 700,
sortable: true,
groupable: false,
toolbar: [{ name: "save", text: "Сохранить" }],
columns: [
{ field: "blocName", title: "Блок", width: "200px" },
{ field: "minMaxFloor", title: "Этаж", width: "70px" },
{ field: "rooms", title: "Комнат", width: "50px" },
{ field: "coefficientValue", title: "Коэффициент этажности", width: "50px" },
{ field: "category", hidden: true, groupHeaderTemplate: "Категория недвижимости: #= value #" }
]
});
}
else {
alert("Выберите застройку!");
}
}
$("#btnSearch").click(function () {
grid_init();
});
</script>
在 coefficientValue 字段中输入一个整数时,一切正常。整数被传递给我的模型。但是当我给我的模型输入一个十进制数字时,传递的是 0(在我的示例中,模型的值应该是 1.5[1])
如何传递十进制数?
【问题讨论】:
-
检查属性名称。确保它不应该有任何拼写错误。在列中添加组名。然后它将传递到服务器端
-
@DeepakKumar 嗨!没有任何拼写错误。对于模型 [0],传递了正确的值 = 2(整数)。
标签: asp.net kendo-ui kendo-grid kendo-asp.net-mvc telerik-grid