I am writing an order-entry system using Angular with Kendo-UI. To add lines to an order, the user will either scan a barcode or pick an item using an item-lookup grid. When an item is picked, the popup edit/add form for order line grid should open up with most of the fields pre-populated with values based on the item picked. The custom edit form contains many read-only informational fields that the sales person needs to see when adding the item, such as item #, description, manufacturer, manufacturer's part number, cost, etc., along with some editable fields such as quantity and price.
Here is the HTML snippet that renders the line grid as well as a simple addButton to simulate an item being picked from the item lookup grid:
Here is the ticketEntryController:
Here is part of the ticketLineController:
When the Add Row button is clicked, the editor popup form opens up, but all fields are empty. How can I populate the fields (like they are when you click the Edit button for an existing row)? Also, of course the sales person could click Cancel from the edit form, in which case the item should not be added to the order line grid.
Here is a Plunker
Thanks,
Lars
Here is the HTML snippet that renders the line grid as well as a simple addButton to simulate an item being picked from the item lookup grid:
<div id=
"wrapper"
class=
"container-fluid"
ng-controller=
"ticketEntryController"
>
<div ng-controller=
"ticketLineController"
>
<div kendo-grid=
"ticketLineGrid"
k-options=
"getTicketLineGridOptions()"
></div>
</div>
<button id=
"addButton"
ng-click=
"addRow()"
class=
"btn btn-primary btn-sm"
>Add Row</button>
</div>
Here is the ticketEntryController:
(
function
() {
'use strict'
;
angular.module(
'app'
).controller(
'ticketEntryController'
, ticketEntryController);
function
ticketEntryController($scope) {
$scope.lineGrid = {};
$scope.addRow =
function
() {
var
item = { itemNo:
'TEST123'
, itemDescr:
'Some description'
};
$scope.$broadcast(
'AddRow'
, item);
}
}
})();
Here is part of the ticketLineController:
function
ticketLineController($scope) {
$scope.$on(
'AddRow'
,
function
(event, item) {
console.log(
"ticketLineController, AddRow: "
+ item.itemNo);
$scope.itemNo = item.itemNo;
$scope.itemDescr = item.itemDescr;
$scope.ticketLineGrid.addRow();
});
When the Add Row button is clicked, the editor popup form opens up, but all fields are empty. How can I populate the fields (like they are when you click the Edit button for an existing row)? Also, of course the sales person could click Cancel from the edit form, in which case the item should not be added to the order line grid.
Here is a Plunker
Thanks,
Lars