Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 剑道UI网格手动保存_Javascript_Kendo Ui_Kendo Grid - Fatal编程技术网

Javascript 剑道UI网格手动保存

Javascript 剑道UI网格手动保存,javascript,kendo-ui,kendo-grid,Javascript,Kendo Ui,Kendo Grid,我有一个剑道网格和一个网格数据源,它将一堆行绑定到剑道网格上。从数据源中提取的每一行都是一个具有导航属性的模型。但是,当我创建新行并使用网格的默认kendo save函数保存它时,导航属性不会初始化。我需要能够在我的网格中为导航属性创建一个新表。我有以下设置 $('#grid').kendoGrid({ dataSource: viewmodel.model.AChecklistCompleteSource, filterable:

我有一个剑道网格和一个网格数据源,它将一堆行绑定到剑道网格上。从数据源中提取的每一行都是一个具有导航属性的模型。但是,当我创建新行并使用网格的默认kendo save函数保存它时,导航属性不会初始化。我需要能够在我的网格中为导航属性创建一个新表。我有以下设置

        $('#grid').kendoGrid({
            dataSource: viewmodel.model.AChecklistCompleteSource,
            filterable: true,
            sortable: true,
            pageable: true,
            columns: [{
                field: "createdBy",
                title: "Created By",
                width: 200
            },
            {
                field: "dateCreated",
                title: "Date Created"
            },
            {
                field: "dateModified",
                title: "Date Modified"
            },
            { command: { text: "View Checklist", click: viewmodel.model.showDetails }, title: " ", width: "180px" }
            ],
            toolbar: [{ name: "create", text: "Create Checklist" }, { name: "save", text: "Save Checklist" }, "cancel"],
            editable: "inline",
            saveChanges: function (e) {
                 //How do I manually save here so that my navigation property is not null for this row's model? 
                if (!confirm("Are you sure you want to save all changes?")) {
                    e.preventDefault();
                }
            },
            height: 500
        });
编辑:

这是我的实体框架代码第一个模型,当剑道网格创建新行时,该模型具有两个为null的导航属性:

    public partial class AChecklistComplete
{
    [Key]
    public int AChecklistCompleteID { get; set; }
    public string createdBy { get; set; }
    public DateTime dateCreated { get; set; }
    public DateTime dateModified { get; set; }
    public virtual ChecklistTop AChecklistTop { get; set; }
    public virtual Aircraft Aircraft { get; set; }
}

我的AChecklistCompleteSource只有这些模型的列表。当kendo创建新行时,它允许我使用此模型创建和保存一行,但Aircraft和AChecklistTop为空,我希望手动初始化它们或自动(如果可能的话),以便我可以在表单上的某个点绑定到它们I.e somefield=AChecklistComplete.Aircraft.somefield

当验证失败时,您应该验证您的模型,那么储蓄也不会发生。所以,你应该附上一个非常有用的KendoValidator,谢谢。但是,当我创建一个新的剑道行时,我将如何在模型中初始化我的导航属性?你能给我一个它应该做什么的提示吗?@JohnEdwards什么导航属性?它指的是什么?如果您向我们展示AChecklistComplete数据元素是什么样子的,这会有所帮助。您提供的唯一信息是它有一个createdBy、dateCreated和dateModified属性。对不起,我不认为需要它,因为我只需要学习如何拦截剑道行创建过程并自己设置对象。我会编辑这篇文章。