//Using the HttpGet method from API to retrieve a list of data.
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 Retrieving Items" + response.data);
}
);
//Configuring the kendo grid
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;
}
//Saving the updated grid data
$scope.saveConsultationParameter=function()
{
if($scope.consultationParamItems!=undefined)
{
Restangular.all('consultparam/consultationparam/saveItems').post($scope.consultationParamItems).then
(
function()
{
alert("Save successful");
},
function()
{
alert("Data Save Failed")
}
)
}
}
//Implementing kendo grid UI
<kendo-grid id="consultationItemsGrid" k-options="consultationItemsGridOptions"></kendo-grid>
//Calling the save method
<div class="panel-ctrls">
<span class="button-icon pull-right"><i class="ti ti-save" ng-click="saveConsultationParameter()"></i></span>
</div>
I am able to load data into the kendo grid. However, when I try to edit or add new rows and then save, the changes are not being saved to the local database. It seems that the updated data is not binding with the data source. I am looking for a solution to this issue. Any help would be appreciated.