-1
//這裏我調用HttpGet方法從API獲取數據列表。如何在更新網格數據後綁定kendo網格?
var apiPath = "http://localhost/unitek/#/ParameterMaster";
Restangular.all(apiPath).getList().then
(
function (response)
{
$scope.consultationParamItems = response.data.plain();
$scope.consultationItemsGridOptions = consultationItemsGridOptionsFn();
},
function (response)
{
alert("Error Retriving Items" + response.data);
}
);
//這裏我配置劍術網格
function consultationItemsGridOptionsFn()
{
var options = {
dataSource:
{
data: $scope.consultationParamItems,
pageSize: 10,
serverPaging: false,
serverSorting: false
},
autoBind:true,
sortable: true,
pageable: true,
resizable: true,
reorderable:true,
groupable: false,
columns:
[
{
field: "ShortDesc",
title: "Parameter Name",
width:"20%"
},
{
field: "Remarks",
title: "Remarks",
width:"15%"
},
{
field: "ConsultationParamSequence",
title: "SEQ",
width:"20%"
},
{
field: "ICD10Code",
title: "ICD10Code",
width:"20%"
},
{
field: "ICD10Remarks",
title: "ICD10Remarks",
width:"20%"
},
{
command: ["edit"], title:" ", width: "100px"
},
{
command: ["destroy"], title: " ", width: "100px"
}
],
editable:true,
//{
// mode: "inline"
//},
toolbar:[{ name: "create", text: "Add " }]
};
return options;
}
//在這裏,我保存更新的網格
$scope.saveConsultationParameter=function()
{
if($scope.consultationParamItems!=undefined)
{
Restangular.all('consultparam/consultationparam/saveItems').post($scope.consultationParamItems).then
(
function()
{
alert("Save successfully");
},
function()
{
alert("Data Save Failed")
}
)
}
}
//我用劍道網格UI
<kendo-grid id="consultationItemsGrid" k-options="consultationItemsGridOptions"></kendo-grid>
//這裏我叫保存方法
<div class="panel-ctrls">
<span class="button-icon pull-right"><i class="ti ti-save" ng-click="saveConsultationParameter()"></i></span>
</div>
我可以加載數據到劍道網格。如果我編輯網格中的數據或添加新的行到網格和保存意味着它應該保存在本地數據庫。但我無法將更新的數據保存到Db.when我調試時,我才知道更新的數據不綁定與datasource.i找不到解決方案。請幫助我。