angularjs - Angular UI Grid validation without edit -


i created ui grid validations. append empty row user fill out. looks validations happen on edit. seems valid empty row not flagging validations start because user has not had interactions cell yet - if user starts edit cell - decides not - validations still not take place.

there 2 scenarios support:

  1. an empty 'new' row
    • no visual validation failures
    • user starts edit - clicks away without making changes
    • validation failures visible
  2. an existing row invalid
    • load data doesn't pass validations
    • validation failures visible without user interaction

plunker: http://plnkr.co/edit/cb9vb9b4itc8z4haahbl?p=preview

  $scope.gridoptions.columndefs = [     { name: 'id',       enablecelledit: false,       width: '10%'     },     { name: 'name',       displayname: 'name',       width: '20%',        validators: {         required: true,         startwith: 'm'       },       celltemplate: 'ui-grid/celltitlevalidator'     },     { name: 'gender',       displayname: 'gender',       width: '20%',        validators: {         required: true       },       celltemplate: 'ui-grid/celltitlevalidator'     }   ]; 

you can set invalid status manually if need new or existing rows.

uigridvalidateservice.setinvalid(datarow, coldef); 

you can coldef using:

$scope.gridapi.grid.getcoldef("columnname") 

Comments