0

This is the json to populate the ui-grid

{
  "radioList": [
    {
      "testId": 4,
      "remarks": null,
      "ordersDto": {
        "orderId": 50808,
        "visitId": null,
        "testMast": {
          "testId": 4,
          "testName": "X-RAY",

        },
        "reportses": [

        ]
      }
    },
    {
      "testId": 4,
      "remarks": "tested",
      "ordersDto": {
        "orderId": 50807,
        "visitId": null,
        "testMast": {
          "testId": 4,
          "testName": "X-RAY",

        },
        "reportses": [
          {
            "report": "very good",
            "instCode": null,
            "folderNo": null
          }
        ]
      }
    }
  ]
}

This is the row template to assign a value in the separate text box.

<div> Reports : <input ng-model="ctrl.report"></input></div> 

For each double click on the row corresponding report if present will be displayed in the text box.

rowTemplate: '<div grid="grid" ng-dblclick="grid.appScope.ctrl.setRadioReports(row.entity);" class="ui-grid-draggable-row" draggable="true"></div>'


vm.setRadioReports = function(row){
      vm.report = angular.copy(row.ordersDto.reportses[0].report);
      row.ordersDto.reportses[0].report = angular.copy(vm.report);// tried copying back but not working.
  }

How can I bind the editable textbox updated value(the value that user entered newly) to the grid and to the array, so that I can save the updated report into db.

Here is the plunker http://plnkr.co/edit/WtN312no4POPrJ8Mh07O?p=preview

// Here updated report value will not be present in the grid, how can I get that value in the vm.gridRadioTest.data

  $scope.save = function(){
     $scope.user.visitMasts[0].radioList = vm.gridRadioTest.data;
  }
user630209
  • 1,123
  • 4
  • 42
  • 93
  • what happens if you just do - `vm.setRadioReports = function(row){ vm.report = (row.ordersDto.reportses[0].report); }` – Developer Nov 14 '16 at 08:49
  • If I update that value in vm.reports, that should reflect in the "row.ordersDto.reportses[0].report" – user630209 Nov 14 '16 at 09:02
  • Any way that we can bind ? or Do I need to loop thru it and bind manually ? – user630209 Nov 14 '16 at 10:37
  • Honestly, I dint get your issue properly. Is it possible to create a fiddle/plunker for this? – Developer Nov 14 '16 at 11:02
  • 1
    Or just try `vm.setRadioReports = function(row){ vm.report = row; }` and in textbox `ng-model="ctrl.ordersDto.reportses[0].report"` - not sure whether this is what you are looking for..as I said, a fiddle/plunker would help – Developer Nov 14 '16 at 11:06
  • This will not work, I had to bind the editable data to grid. How that can be done ? – user630209 Nov 15 '16 at 06:29

0 Answers0