javascript - 未捕获的语法错误 : Unexpected number in kendo ui grid

标签 javascript kendo-ui kendo-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

谁知道请帮帮我

提前致谢

最佳答案

正如我在 basic sample 中看到的那样, 列定义的参数 width 应该是数字而不是字符串

 { field: "no_of_issues", title: "No. of issues", width: 100 },

UPD:正如 Pavel Petrman 所说,现在可以接受使用字符串宽度来设置适当的比例。例如here作者使用了“px”,你也可以使用相对点(“100%”)。

关于javascript - 未捕获的语法错误 : Unexpected number in kendo ui grid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15782508/

相关文章:

javascript - Kendo UI 网格复选框列字段未定义

javascript - 视口(viewport)大小和滚动

javascript - 无法将图像高度和宽度分配给 typescript 中的输入类型框

javascript - 修改 CSS 选择器 :after with JavaScript

kendo-ui - 按外键列文本排序而不是 Kendo Grid MVC 中的值

javascript - jQuery:如何更改点击事件的数据绑定(bind)?

grails - 剑道网格按降序排序

JavaScript问题——onMouseOver事件

css - 从输入字段中删除 IE 10 清除按钮

c# - 将 EditorTemplate 添加到 Kendo 网格