How can save all changed data in details grid (table)
I was worked simple web application using asp.net web api and angularjs (javascript). In this app I have one master grid, and when I click on button inside row, then the modal dialog will be opened. Modal dialog containd detail grid (table) which have many items. See following picture:
Each items in his data contains parentId. In my case each detail grid item contains id = 1, which we can see in the next picture:
This solution (when I click 'plus' button) working fine (only Kolicina field can make change). But, we must click row by row plus button for save all changes. My question is, how can implement functionality, in which we will have only one button in modal dialog for save all row changes. I assume that array (with all item changes) should be forwarded to the web api controller method.
Thanks for any useful information.
EDIT
My html modal looks like:
<div id="vipZaglavljeModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content" style="overflow:scroll;max-height:700px;width:750px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">VIP Stavke</h4>
</div>
<div class="modal-body">
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"><button ng-click="vipZaglavljePut(stavka.Id, stavka)" ng-disabled="((formatDateScope(stavka.VIPZaglavlje.Pocetak) < trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) > trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme))" class="btn btn-primary" style="margin-top:-5px">+</button></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" style="font-size:medium">OK</button>
<!--<button type="button" class="btn btn-primary" ng-click="osnovnaSredstvaDelete()" style="font-size:medium">Da</button>-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
javascript angularjs asp.net-web-api asp.net-mvc-5
add a comment |
I was worked simple web application using asp.net web api and angularjs (javascript). In this app I have one master grid, and when I click on button inside row, then the modal dialog will be opened. Modal dialog containd detail grid (table) which have many items. See following picture:
Each items in his data contains parentId. In my case each detail grid item contains id = 1, which we can see in the next picture:
This solution (when I click 'plus' button) working fine (only Kolicina field can make change). But, we must click row by row plus button for save all changes. My question is, how can implement functionality, in which we will have only one button in modal dialog for save all row changes. I assume that array (with all item changes) should be forwarded to the web api controller method.
Thanks for any useful information.
EDIT
My html modal looks like:
<div id="vipZaglavljeModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content" style="overflow:scroll;max-height:700px;width:750px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">VIP Stavke</h4>
</div>
<div class="modal-body">
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"><button ng-click="vipZaglavljePut(stavka.Id, stavka)" ng-disabled="((formatDateScope(stavka.VIPZaglavlje.Pocetak) < trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) > trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme))" class="btn btn-primary" style="margin-top:-5px">+</button></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" style="font-size:medium">OK</button>
<!--<button type="button" class="btn btn-primary" ng-click="osnovnaSredstvaDelete()" style="font-size:medium">Da</button>-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
javascript angularjs asp.net-web-api asp.net-mvc-5
Could you show your code?
– BartoszTermena
Nov 13 '18 at 13:12
I can. This is angularjs service function:var _vipZaglavljePut = function (id, vipZaglavlje) var deferred = $q.defer(); $http.put("/api/VIPZaglavlje/" + id, vipZaglavlje).then(function (result) deferred.resolve(result.data); , function () deferred.reject(); ); return deferred.promise;
vipZaglavlje is object.
– oknevermind
Nov 13 '18 at 13:24
This is angularjs controller function:$scope.vipZaglavljePut = function (id, vipZaglavlje) VIPZaglavlje.vipZaglavljePut(id, vipZaglavlje).then( function () for (var i = 0; i < $scope.stavke.length; i++) if ($scope.stavke[i].Id == id) $scope.stavke[i] = vipZaglavlje; , function () alert("Desila se greška!") );
– oknevermind
Nov 13 '18 at 13:27
This is web api method [httpput]:// PUT: api/VIPZaglavlje/5 public void Put(int id, [FromBody]VIPStavkePutModel value) try var userName = User.Identity.Name; var VIPStavke = _db.VIPStavke.Where(x => x.Id.Equals(id)).FirstOrDefault(); VIPStavke.Kolicina = value.Kolicina; _db.SaveChanges(); catch (Exception ex) var message = ex.Message;
– oknevermind
Nov 13 '18 at 13:29
In html I have html table with ng-repeat loop (displayed in picture 1 above). Instead blue 'plus' button, I want implement only one button, at the bottom of the modal (for save all changes).
– oknevermind
Nov 13 '18 at 13:33
add a comment |
I was worked simple web application using asp.net web api and angularjs (javascript). In this app I have one master grid, and when I click on button inside row, then the modal dialog will be opened. Modal dialog containd detail grid (table) which have many items. See following picture:
Each items in his data contains parentId. In my case each detail grid item contains id = 1, which we can see in the next picture:
This solution (when I click 'plus' button) working fine (only Kolicina field can make change). But, we must click row by row plus button for save all changes. My question is, how can implement functionality, in which we will have only one button in modal dialog for save all row changes. I assume that array (with all item changes) should be forwarded to the web api controller method.
Thanks for any useful information.
EDIT
My html modal looks like:
<div id="vipZaglavljeModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content" style="overflow:scroll;max-height:700px;width:750px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">VIP Stavke</h4>
</div>
<div class="modal-body">
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"><button ng-click="vipZaglavljePut(stavka.Id, stavka)" ng-disabled="((formatDateScope(stavka.VIPZaglavlje.Pocetak) < trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) > trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme))" class="btn btn-primary" style="margin-top:-5px">+</button></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" style="font-size:medium">OK</button>
<!--<button type="button" class="btn btn-primary" ng-click="osnovnaSredstvaDelete()" style="font-size:medium">Da</button>-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
javascript angularjs asp.net-web-api asp.net-mvc-5
I was worked simple web application using asp.net web api and angularjs (javascript). In this app I have one master grid, and when I click on button inside row, then the modal dialog will be opened. Modal dialog containd detail grid (table) which have many items. See following picture:
Each items in his data contains parentId. In my case each detail grid item contains id = 1, which we can see in the next picture:
This solution (when I click 'plus' button) working fine (only Kolicina field can make change). But, we must click row by row plus button for save all changes. My question is, how can implement functionality, in which we will have only one button in modal dialog for save all row changes. I assume that array (with all item changes) should be forwarded to the web api controller method.
Thanks for any useful information.
EDIT
My html modal looks like:
<div id="vipZaglavljeModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content" style="overflow:scroll;max-height:700px;width:750px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">VIP Stavke</h4>
</div>
<div class="modal-body">
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"><button ng-click="vipZaglavljePut(stavka.Id, stavka)" ng-disabled="((formatDateScope(stavka.VIPZaglavlje.Pocetak) < trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) > trenutniDatumIVrijeme) || (formatDateScope(stavka.VIPZaglavlje.Pocetak) > trenutniDatumIVrijeme && formatDateScope(stavka.VIPZaglavlje.Kraj) < trenutniDatumIVrijeme))" class="btn btn-primary" style="margin-top:-5px">+</button></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" style="font-size:medium">OK</button>
<!--<button type="button" class="btn btn-primary" ng-click="osnovnaSredstvaDelete()" style="font-size:medium">Da</button>-->
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
javascript angularjs asp.net-web-api asp.net-mvc-5
javascript angularjs asp.net-web-api asp.net-mvc-5
edited Nov 13 '18 at 13:56
oknevermind
asked Nov 13 '18 at 13:02
oknevermindoknevermind
61114
61114
Could you show your code?
– BartoszTermena
Nov 13 '18 at 13:12
I can. This is angularjs service function:var _vipZaglavljePut = function (id, vipZaglavlje) var deferred = $q.defer(); $http.put("/api/VIPZaglavlje/" + id, vipZaglavlje).then(function (result) deferred.resolve(result.data); , function () deferred.reject(); ); return deferred.promise;
vipZaglavlje is object.
– oknevermind
Nov 13 '18 at 13:24
This is angularjs controller function:$scope.vipZaglavljePut = function (id, vipZaglavlje) VIPZaglavlje.vipZaglavljePut(id, vipZaglavlje).then( function () for (var i = 0; i < $scope.stavke.length; i++) if ($scope.stavke[i].Id == id) $scope.stavke[i] = vipZaglavlje; , function () alert("Desila se greška!") );
– oknevermind
Nov 13 '18 at 13:27
This is web api method [httpput]:// PUT: api/VIPZaglavlje/5 public void Put(int id, [FromBody]VIPStavkePutModel value) try var userName = User.Identity.Name; var VIPStavke = _db.VIPStavke.Where(x => x.Id.Equals(id)).FirstOrDefault(); VIPStavke.Kolicina = value.Kolicina; _db.SaveChanges(); catch (Exception ex) var message = ex.Message;
– oknevermind
Nov 13 '18 at 13:29
In html I have html table with ng-repeat loop (displayed in picture 1 above). Instead blue 'plus' button, I want implement only one button, at the bottom of the modal (for save all changes).
– oknevermind
Nov 13 '18 at 13:33
add a comment |
Could you show your code?
– BartoszTermena
Nov 13 '18 at 13:12
I can. This is angularjs service function:var _vipZaglavljePut = function (id, vipZaglavlje) var deferred = $q.defer(); $http.put("/api/VIPZaglavlje/" + id, vipZaglavlje).then(function (result) deferred.resolve(result.data); , function () deferred.reject(); ); return deferred.promise;
vipZaglavlje is object.
– oknevermind
Nov 13 '18 at 13:24
This is angularjs controller function:$scope.vipZaglavljePut = function (id, vipZaglavlje) VIPZaglavlje.vipZaglavljePut(id, vipZaglavlje).then( function () for (var i = 0; i < $scope.stavke.length; i++) if ($scope.stavke[i].Id == id) $scope.stavke[i] = vipZaglavlje; , function () alert("Desila se greška!") );
– oknevermind
Nov 13 '18 at 13:27
This is web api method [httpput]:// PUT: api/VIPZaglavlje/5 public void Put(int id, [FromBody]VIPStavkePutModel value) try var userName = User.Identity.Name; var VIPStavke = _db.VIPStavke.Where(x => x.Id.Equals(id)).FirstOrDefault(); VIPStavke.Kolicina = value.Kolicina; _db.SaveChanges(); catch (Exception ex) var message = ex.Message;
– oknevermind
Nov 13 '18 at 13:29
In html I have html table with ng-repeat loop (displayed in picture 1 above). Instead blue 'plus' button, I want implement only one button, at the bottom of the modal (for save all changes).
– oknevermind
Nov 13 '18 at 13:33
Could you show your code?
– BartoszTermena
Nov 13 '18 at 13:12
Could you show your code?
– BartoszTermena
Nov 13 '18 at 13:12
I can. This is angularjs service function:
var _vipZaglavljePut = function (id, vipZaglavlje) var deferred = $q.defer(); $http.put("/api/VIPZaglavlje/" + id, vipZaglavlje).then(function (result) deferred.resolve(result.data); , function () deferred.reject(); ); return deferred.promise;
vipZaglavlje is object.– oknevermind
Nov 13 '18 at 13:24
I can. This is angularjs service function:
var _vipZaglavljePut = function (id, vipZaglavlje) var deferred = $q.defer(); $http.put("/api/VIPZaglavlje/" + id, vipZaglavlje).then(function (result) deferred.resolve(result.data); , function () deferred.reject(); ); return deferred.promise;
vipZaglavlje is object.– oknevermind
Nov 13 '18 at 13:24
This is angularjs controller function:
$scope.vipZaglavljePut = function (id, vipZaglavlje) VIPZaglavlje.vipZaglavljePut(id, vipZaglavlje).then( function () for (var i = 0; i < $scope.stavke.length; i++) if ($scope.stavke[i].Id == id) $scope.stavke[i] = vipZaglavlje; , function () alert("Desila se greška!") );
– oknevermind
Nov 13 '18 at 13:27
This is angularjs controller function:
$scope.vipZaglavljePut = function (id, vipZaglavlje) VIPZaglavlje.vipZaglavljePut(id, vipZaglavlje).then( function () for (var i = 0; i < $scope.stavke.length; i++) if ($scope.stavke[i].Id == id) $scope.stavke[i] = vipZaglavlje; , function () alert("Desila se greška!") );
– oknevermind
Nov 13 '18 at 13:27
This is web api method [httpput]:
// PUT: api/VIPZaglavlje/5 public void Put(int id, [FromBody]VIPStavkePutModel value) try var userName = User.Identity.Name; var VIPStavke = _db.VIPStavke.Where(x => x.Id.Equals(id)).FirstOrDefault(); VIPStavke.Kolicina = value.Kolicina; _db.SaveChanges(); catch (Exception ex) var message = ex.Message;
– oknevermind
Nov 13 '18 at 13:29
This is web api method [httpput]:
// PUT: api/VIPZaglavlje/5 public void Put(int id, [FromBody]VIPStavkePutModel value) try var userName = User.Identity.Name; var VIPStavke = _db.VIPStavke.Where(x => x.Id.Equals(id)).FirstOrDefault(); VIPStavke.Kolicina = value.Kolicina; _db.SaveChanges(); catch (Exception ex) var message = ex.Message;
– oknevermind
Nov 13 '18 at 13:29
In html I have html table with ng-repeat loop (displayed in picture 1 above). Instead blue 'plus' button, I want implement only one button, at the bottom of the modal (for save all changes).
– oknevermind
Nov 13 '18 at 13:33
In html I have html table with ng-repeat loop (displayed in picture 1 above). Instead blue 'plus' button, I want implement only one button, at the bottom of the modal (for save all changes).
– oknevermind
Nov 13 '18 at 13:33
add a comment |
1 Answer
1
active
oldest
votes
Do i understand correctly - you want to have only one button for save all datas
from table. You can add a checkboxes in each row of table and in the top add button which sums all checked datas and send them on
HTML :
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"> <button class="btn" ng-click="vipZaglavljePut(stavka)">+</button></td>
</tr>
</tbody>
</table>
</div>
<div ng-if="Kolicina">id : Kolicina</div>
JS:
$scope.vipZaglavljePut = function (stavka)
console.log(stavka.Kolicina);
$scope.id = stavka.Id;
$scope.Kolicina = stavka.Kolicina;
Here is plunker : http://plnkr.co/edit/h1Jao3YfbFCd2n33bQtk?p=preview
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281601%2fhow-can-save-all-changed-data-in-details-grid-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Do i understand correctly - you want to have only one button for save all datas
from table. You can add a checkboxes in each row of table and in the top add button which sums all checked datas and send them on
HTML :
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"> <button class="btn" ng-click="vipZaglavljePut(stavka)">+</button></td>
</tr>
</tbody>
</table>
</div>
<div ng-if="Kolicina">id : Kolicina</div>
JS:
$scope.vipZaglavljePut = function (stavka)
console.log(stavka.Kolicina);
$scope.id = stavka.Id;
$scope.Kolicina = stavka.Kolicina;
Here is plunker : http://plnkr.co/edit/h1Jao3YfbFCd2n33bQtk?p=preview
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
add a comment |
Do i understand correctly - you want to have only one button for save all datas
from table. You can add a checkboxes in each row of table and in the top add button which sums all checked datas and send them on
HTML :
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"> <button class="btn" ng-click="vipZaglavljePut(stavka)">+</button></td>
</tr>
</tbody>
</table>
</div>
<div ng-if="Kolicina">id : Kolicina</div>
JS:
$scope.vipZaglavljePut = function (stavka)
console.log(stavka.Kolicina);
$scope.id = stavka.Id;
$scope.Kolicina = stavka.Kolicina;
Here is plunker : http://plnkr.co/edit/h1Jao3YfbFCd2n33bQtk?p=preview
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
add a comment |
Do i understand correctly - you want to have only one button for save all datas
from table. You can add a checkboxes in each row of table and in the top add button which sums all checked datas and send them on
HTML :
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"> <button class="btn" ng-click="vipZaglavljePut(stavka)">+</button></td>
</tr>
</tbody>
</table>
</div>
<div ng-if="Kolicina">id : Kolicina</div>
JS:
$scope.vipZaglavljePut = function (stavka)
console.log(stavka.Kolicina);
$scope.id = stavka.Id;
$scope.Kolicina = stavka.Kolicina;
Here is plunker : http://plnkr.co/edit/h1Jao3YfbFCd2n33bQtk?p=preview
Do i understand correctly - you want to have only one button for save all datas
from table. You can add a checkboxes in each row of table and in the top add button which sums all checked datas and send them on
HTML :
<table id="myTableModal" class="table table-bordered table-condensed">
<thead>
<tr>
<th style="padding-left:15px;font-size:medium;">Id</th>
<th style="font-size:medium">Sifra</th>
<th style="font-size:medium">Naziv</th>
<th style="font-size:medium">Kolicina</th>
<th style="font-size:medium;width:70px;">Prodavnica</th>
<th style="font-size:medium">***</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stavka in stavke track by $index">
<td style="padding-left:15px;font-size:medium;padding-top:12px;">stavka.Id</td>
<td style="font-size:medium;padding-top:12px;">stavka.Sifra</td>
<td style="font-size:medium;padding-top:12px;">stavka.Naziv</td>
<td style="font-size:medium;padding-top:12px;"><input type="text" class="form-control" ng-model="stavka.Kolicina" style="width:70px;margin-top:-5px;"/></td><!--ng-class=" nakonStoKliknesSave: kliknutoNaSave[$index] "-->
<td style="font-size:medium;padding-top:12px;">stavka.Prodavnica</td>
<td style="font-size:medium;padding-top:12px;"> <button class="btn" ng-click="vipZaglavljePut(stavka)">+</button></td>
</tr>
</tbody>
</table>
</div>
<div ng-if="Kolicina">id : Kolicina</div>
JS:
$scope.vipZaglavljePut = function (stavka)
console.log(stavka.Kolicina);
$scope.id = stavka.Id;
$scope.Kolicina = stavka.Kolicina;
Here is plunker : http://plnkr.co/edit/h1Jao3YfbFCd2n33bQtk?p=preview
edited Nov 13 '18 at 14:38
answered Nov 13 '18 at 13:43
BartoszTermenaBartoszTermena
7381311
7381311
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
add a comment |
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
I have edited my post. As you can see, I have input value, for change field 'Kolicina'. Is there a possibility of implementation without a checkbox control?
– oknevermind
Nov 13 '18 at 13:58
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
@oknevermind Something like this?
– BartoszTermena
Nov 13 '18 at 14:38
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281601%2fhow-can-save-all-changed-data-in-details-grid-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you show your code?
– BartoszTermena
Nov 13 '18 at 13:12
I can. This is angularjs service function:
var _vipZaglavljePut = function (id, vipZaglavlje) var deferred = $q.defer(); $http.put("/api/VIPZaglavlje/" + id, vipZaglavlje).then(function (result) deferred.resolve(result.data); , function () deferred.reject(); ); return deferred.promise;
vipZaglavlje is object.– oknevermind
Nov 13 '18 at 13:24
This is angularjs controller function:
$scope.vipZaglavljePut = function (id, vipZaglavlje) VIPZaglavlje.vipZaglavljePut(id, vipZaglavlje).then( function () for (var i = 0; i < $scope.stavke.length; i++) if ($scope.stavke[i].Id == id) $scope.stavke[i] = vipZaglavlje; , function () alert("Desila se greška!") );
– oknevermind
Nov 13 '18 at 13:27
This is web api method [httpput]:
// PUT: api/VIPZaglavlje/5 public void Put(int id, [FromBody]VIPStavkePutModel value) try var userName = User.Identity.Name; var VIPStavke = _db.VIPStavke.Where(x => x.Id.Equals(id)).FirstOrDefault(); VIPStavke.Kolicina = value.Kolicina; _db.SaveChanges(); catch (Exception ex) var message = ex.Message;
– oknevermind
Nov 13 '18 at 13:29
In html I have html table with ng-repeat loop (displayed in picture 1 above). Instead blue 'plus' button, I want implement only one button, at the bottom of the modal (for save all changes).
– oknevermind
Nov 13 '18 at 13:33