|
355 | 355 | // Skip attaching if edit and cellNav is not enabled
|
356 | 356 | if (!uiGridCtrl.grid.api.edit || !uiGridCtrl.grid.api.cellNav) { return; }
|
357 | 357 |
|
| 358 | + var containerId = controllers[1].containerId; |
| 359 | + //no need to process for other containers |
| 360 | + if (containerId !== 'body') { |
| 361 | + return; |
| 362 | + } |
| 363 | + |
| 364 | + //refocus on the grid |
358 | 365 | $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () {
|
359 |
| - $elm[0].focus(); |
| 366 | + uiGridCtrl.focus(); |
360 | 367 | });
|
361 | 368 | $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () {
|
362 |
| - $elm[0].focus(); |
| 369 | + uiGridCtrl.focus(); |
363 | 370 | });
|
364 | 371 |
|
365 | 372 | }
|
|
1042 | 1049 |
|
1043 | 1050 | var handleFileSelect = function( event ){
|
1044 | 1051 | var target = event.srcElement || event.target;
|
1045 |
| - |
| 1052 | + |
1046 | 1053 | if (target && target.files && target.files.length > 0) {
|
1047 | 1054 | /**
|
1048 | 1055 | * @ngdoc property
|
|
1051 | 1058 | * @description A function that should be called when any files have been chosen
|
1052 | 1059 | * by the user. You should use this to process the files appropriately for your
|
1053 | 1060 | * application.
|
1054 |
| - * |
1055 |
| - * It passes the gridCol, the gridRow (from which you can get gridRow.entity), |
| 1061 | + * |
| 1062 | + * It passes the gridCol, the gridRow (from which you can get gridRow.entity), |
1056 | 1063 | * and the files. The files are in the format as returned from the file chooser,
|
1057 | 1064 | * an array of files, with each having useful information such as:
|
1058 | 1065 | * - `files[0].lastModifiedDate`
|
1059 | 1066 | * - `files[0].name`
|
1060 | 1067 | * - `files[0].size` (appears to be in bytes)
|
1061 | 1068 | * - `files[0].type` (MIME type by the looks)
|
1062 |
| - * |
1063 |
| - * Typically you would do something with these files - most commonly you would |
| 1069 | + * |
| 1070 | + * Typically you would do something with these files - most commonly you would |
1064 | 1071 | * use the filename or read the file itself in. The example function does both.
|
1065 |
| - * |
| 1072 | + * |
1066 | 1073 | * @example
|
1067 | 1074 | * <pre>
|
1068 | 1075 | * editFileChooserCallBack: function(gridRow, gridCol, files ){
|
1069 | 1076 | * // ignore all but the first file, it can only choose one anyway
|
1070 | 1077 | * // set the filename into this column
|
1071 | 1078 | * gridRow.entity.filename = file[0].name;
|
1072 |
| - * |
| 1079 | + * |
1073 | 1080 | * // read the file and set it into a hidden column, which we may do stuff with later
|
1074 | 1081 | * var setFile = function(fileContent){
|
1075 | 1082 | * gridRow.entity.file = fileContent.currentTarget.result;
|
|
1085 | 1092 | } else {
|
1086 | 1093 | gridUtil.logError('You need to set colDef.editFileChooserCallback to use the file chooser');
|
1087 | 1094 | }
|
1088 |
| - |
| 1095 | + |
1089 | 1096 | target.form.reset();
|
1090 | 1097 | $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
|
1091 | 1098 | } else {
|
1092 | 1099 | $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
1093 | 1100 | }
|
1094 | 1101 | };
|
1095 |
| - |
| 1102 | + |
1096 | 1103 | $elm[0].addEventListener('change', handleFileSelect, false); // TODO: why the false on the end? Google
|
1097 |
| - |
| 1104 | + |
1098 | 1105 | $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
|
1099 | 1106 | $elm[0].focus();
|
1100 | 1107 | $elm[0].select();
|
|
0 commit comments