如何使用devextreme进行crud操作

时间:2015-12-07 08:39:14

标签: grid devexpress crud devextreme

$(document).ready(function () {
        var gridOptions = {
            color: 'LightSkyBlue',
            dataSource: gridData,
            paging: { pageSize: 15 },
            height: "90%",
            selection: { mode: "single" },
            editing: {
                mode: "form",
                editEnabled: true,
                insertEnabled: true,
                removeEnabled: true
            },
            filterRow: { visible: false },
            columnChooser: { enabled: true },
            columnAutoWidth: true,
            searchPanel: { visible: true },
            groupPanel: { visible: true },
            allowColumnReordering: true,
            allowColumnResizing: true,
            rowAlternationEnabled: false,
            rowClick: function (data) {
            },
            selectionChanged: function (selectedItems) {
            },
            @*columns: [
                @foreach(var item in Model.Columns){
                    <text>
                        { dataField: "@item.FieldName", caption: "@item.Caption" },
                    </text>
                }
            ]*@
        };

1 个答案:

答案 0 :(得分:2)

来源: How to implement CRUD operations with a DataSource

  

使用从中获取数据的DataSource实现CRUD操作   远程休息服务。 DataSource对象不实现CRUD   开箱即用的操作。我们可以使用jQuery.ajax来做到这一点。它是   还需要调用DataSource.load方法来&#34;通知&#34;您的   小部件,有必要重新加载其内容。

使用视图将项目添加到数据源的示例代码段:

Application1.addView = function (params) {
    var viewModel = {
        categoryName: ko.observable(),
        btnSaveClick: function (e) {
            var category = {
                CategoryID: 0,
                CategoryName: viewModel.categoryName()
            }
            Application1.db.insert(category).done(function (data) {
                app.back();
            });
        }
    };
    return viewModel;
};

<强>参考文献:
How to implement CRUD operations with a DataSource
dxDataGrid - How to implement a custom store with CRUD operations (SQLite)

希望这有助于您前进。 :)