gpt4 book ai didi

datasource - 剑道UI : programmatically setting a datasource model

转载 作者:行者123 更新时间:2023-12-04 02:06:03 28 4
gpt4 key购买 nike

我想以编程方式设置我的数据源的模型。像这样的东西:

var ds = new kendo.data.DataSource({ //... });

var mod = kendo.data.Model.define({
fields: data
});

ds.model = mod;

这可能吗?如何?谢谢你。

最佳答案

当然可以,但是您必须在 DataSource 字段 schema.model 中设置它(参见 schema.model reference )

如本页所示,您将拥有如下内容:

// Definition of your model
var Product = kendo.data.Model.define({
id: "ProductID",
fields: {
ProductID: {
//this field will not be editable (default value is true)
editable: false,
// a defaultValue will not be assigned (default value is false)
nullable: true
},
ProductName: {
validation: { //set validation rules
required: true
}
},
UnitPrice: {
//data type of the field {Number|String|Boolean|Date} default is String
type: "number",
// used when new model is created
defaultValue: 42,
validation: {
required: true,
min: 1
}
}
}
});

// Map this model to your DataSource object
var dataSource = new kendo.data.DataSource({
schema: {
model: Product // Use the existing Product model
}
});

关于datasource - 剑道UI : programmatically setting a datasource model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13579851/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com