2015-12-07 89 views
0
$(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> 
       } 
      ]*@ 
     }; 
+2

請在問題主體中描述您的問題,而不是僅發佈代碼。 –

回答

1

來源:How to implement CRUD operations with a DataSource

爲了實現與從 遠程REST服務獲得的數據一個DataSource CRUD操作。 DataSource對象不實現CRUD 開箱即用的操作。我們可以使用jQuery.ajax來做到這一點。調用DataSource.load方法來「通知」您的 小部件有必要重新加載其內容也是必需的,它也是 。

示例代碼片段使用視圖來添加項目數據源:

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)

希望這有助於你前進。 :)