未捕获的SyntaxError:剑道ui网格中的意外数字
Uncaught SyntaxError: Unexpected number in kendo ui grid
我使用剑道网格为我的门户网站网格的代码为
//Grid for award adding
var griddataSource = new kendo.data.DataSource({
dataType: "json",
transport: {
read: function(o){
//o.success([]);
url: ServiceBaseUrl+"/Magazine/getsubscriptiondetails?magazineid="+magazine_id,
dataType: "json",
},
create: function(o) {
var item = o.data;
//assign a unique ID and return the record
item.id = len;
o.success(item);
len++;
},
destroy: function(o) {
o.success();
},
update: function(o){
o.success();
}
},
autoSync: false,
schema: {
model: {
id : "id",
fields: {
magazine_subscription_id: { editable: true},
no_of_issues:{editable: true, type:"number", validation: {
required: {
message: "No of issues required"
},
min: 1
}
},
subscription_name: { editable: true, type:"string", validation: {
required: {
message: "Package Name required"
}
}
},
subscription_key: { editable: true, type:"string", validation: {
required: {
message: "Subscription Key required"
}
} },
price_inr: { type: "number", validation: {
required: {
message: "Price(INR) Key required"
}, min: .1} },
price: { type: "number", validation: {
required: {
message: "Price($) Key required"
},
min: .1} },
discount_type: { type:"string", editable: true, nullable: false},
discount_no_of_free_issue: { type: "number" ,validation: { min: 1}}
}
}
}
});
$("#grid").kendoGrid({
dataSource: griddataSource,
pageable: false,
selectable: "multiple",
sortable: true,
filterable: false,
reorderable: true,
scrollable: false,
toolbar: ["create"],
columns:
[
{ field: "no_of_issues", title: "No. of issues", width: "100px", format: ""},
{ field: "subscription_name", title: "Package Name", width: "150px" },
{ field: "subscription_key", title: "Subscription Key", width: "150px" },
{ field: "price_inr", title: "Price (INR)", width: "75px" },
{ field: "price", title: "Price ($)", width: "75px" },
{ field: "discount_type", title: "Type", width: "150px", values: type},
{ field: "discount_no_of_free_issue", title: "Discount / No. of Issues", width: "150px", format: ""},
{ command: ["edit", "destroy"], title: " ", width: "210px" }
],
editable: "inline"
});
网格正确显示内容。但是当我向网格中添加新记录时,会显示一个错误
Uncaught SyntaxError: Unexpected number
如果有人知道这一点,请帮助我
thanks in advance
正如我在基本示例中看到的,列定义的参数width应该是一个数字而不是字符串
{ field: "no_of_issues", title: "No. of issues", width: 100 },
UPD:正如Pavel Petrman所说,现在可以使用字符串宽度来设置适当的比例。例如这里作者使用了"px",你也可以使用相对点("100%")
我刚刚遇到了这个问题。这个问题很容易解决,但很难追踪。我通过输入
消除了错误create: function(options) {
options.success({ID:x});
}
,其中x是有效的(在我的例子中它是一个字符串)。
不考虑对象中有其他内容:
options.success({ID:x, foo:bar, ... , stuff: {}, ...})
重要的是与模型id设置相对应的有效id(同样,在我的情况下
)schema: {
model: {
id: "ID",
)。
对于这个特殊的问题,我检查len
参数
我得到了这种错误的列映射。我有
columns: [
{
field: 'Name',
template: vm.categoryNameTreeTemplate
},
{ field: 'Description' },
{ field: 'Category Code' }, -- this one is wrong
{ field: 'IsDeleted' },
{ command: ['create', 'edit'] }
]
但正确的版本是
columns: [
{
field: 'Name',
template: vm.categoryNameTreeTemplate
},
{ field: 'Description' },
{ field: 'CategoryCode' }, -- correct
{ field: 'IsDeleted' },
{ command: ['create', 'edit'] }
]
相关文章:
- 剑道网格jQuery动画()问题
- 使用Dnamics CRM 2011中的JavaScript读取子网格的所有记录,而不考虑活动页面
- 分析高度属性时出现意外值{{specs.height}}.index.html
- 我可以更改剑道UI网格吗's的外键值
- 铬:“;未捕获的语法错误:意外的标记:"
- Javascript未捕获语法错误意外的标识符错误
- jqGrid树网格问题
- 在Three.js中导出网格会提高性能吗
- 如何在剑道网格初始化后设置pageSizes
- 未捕获的语法错误:意外的标记{
- 在threejs中使用纹理网格和线框网格
- 如何在可分组的剑道网格中设置空数据文本
- "未捕获的语法错误:意外的标记}"
- 如何在Angular UI网格中选择下一行
- ExtJS网格单元格编辑器,防止焦点松动问题
- 多维数据集网格未在指定的分区中绘制
- Uncaught SyntaxError:在剑道网格中动态生成列时出现意外数字
- 网格中的树视图给出“意外令牌:”
- jquery在DOM中返回了Kendo网格的意外类型
- 未捕获的SyntaxError:剑道ui网格中的意外数字