Comments on: Create a Modal Row Editor for UI-Grid in Minutes https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/ Wed, 29 Apr 2020 09:02:00 +0000 hourly 1 By: Jorge Luis Ortiz https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-347 Wed, 04 Oct 2017 19:42:00 +0000 https://brianhann.com/?p=162#comment-347 Hi Brian. The some example in angular 4?

]]>
By: Varsha https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-340 Tue, 25 Jul 2017 03:42:00 +0000 https://brianhann.com/?p=162#comment-340 Hi Brian
May i know whether a single column in a datagrid have multiple datatypes in angularjs? Like I have a column which contains checkbox, dropdowns and textbox. Please do reply.

]]>
By: Eduardo Fernandez https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-320 Fri, 31 Mar 2017 20:15:00 +0000 https://brianhann.com/?p=162#comment-320 Why is not working here?
https://plnkr.co/edit/D48xcomnXdClccMnl5Jj?p=info

]]>
By: Gajendrasinh Zala https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-276 Tue, 18 Oct 2016 13:02:00 +0000 https://brianhann.com/?p=162#comment-276 http call not working on save function

function RowEditCtrl($uibModalInstance, grid, row, $http) {
var vm = this;

vm.entity = angular.copy(row.entity);

vm.save = save;

function save(ignore) {

vm.save = save;

row.entity = angular.extend(row.entity, vm.entity);

$http.post(‘/contacts/update’, vm.entity)
.success(function(data) {
console.log(“done”)
$uibModalInstance.close(row.entity);
})
.error(function(err) {
console.log(‘Error: ‘ + err);
});

}
};

]]>
By: Gajendrasinh Zala https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-274 Mon, 17 Oct 2016 09:54:00 +0000 https://brianhann.com/?p=162#comment-274 Hi,

When i am going to call api on save function it not working

this is my code

function RowEditCtrl($uibModalInstance, grid, row, $http) {
var vm = this;

vm.entity = angular.copy(row.entity);

vm.save = save;

function save(ignore) {

vm.save = save;

row.entity = angular.extend(row.entity, vm.entity);

$http.post(‘/contacts/update’, vm.entity)
.success(function(data) {
console.log(“done”)
$uibModalInstance.close(row.entity);
})
.error(function(err) {
console.log(‘Error: ‘ + err);
});

}
};

]]>
By: Ashokkumar S Sampath https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-242 Sat, 04 Jun 2016 20:51:00 +0000 https://brianhann.com/?p=162#comment-242 Hi Brian,
I am trying open a modal on click, but it’s not working.Please find my code

main controller1.
function typeListGet(){
var vm=this;
vm.editRow = RowEditor.editRow;
$http.get(‘/test’).then(
function success(response) {
$scope.urlid=response.data.result.rows;
$scope.gridOptions.enableFiltering=true;
$scope.gridOptions.columnDefs = [
{
name: ‘type’,
enableCellEdit: false
},

{
name: ‘adtype’,
displayName: ‘AD Type’
},
{
field: ‘id’,
name: ”,
cellTemplate: ‘/templates/dashboard/editButton.html’,
width:50,
enableSorting: false,
enableFiltering:false
}
];
},

function error(response) {
var data = response.data;
});
}
rowedit controller

angular.module(‘yapp’)

.controller(‘ModalInstanceCtrl’,[‘$scope’, ‘$modalInstance’, ‘grid’,’row’, function($scope, $modalInstance, grid, row) {
function RowEditCtrl($modalInstance, PersonSchema, grid, row) {
var vm = this;
vm.schema = PersonSchema;
vm.entity = angular.copy(row.entity);
vm.form = [
‘name’,
‘company’,
‘phone’,
‘address.city’
];
vm.grid = grid;
vm.row = row;
vm.save = save;
function save() {

// Copy row values over

row.entity = angular.extend(row.entity, vm.entity);

$modalInstance.close(row.entity);
}

}
}]);
—-
service

angular.module(‘yapp’)
.factory(‘RowEditor’,[‘$rootScope’, ‘$modal’, function($rootScope, $modal) {
var service = {};
service.editRow = editRow;
function editRow(grid, row) {
console.log(‘in service’);
$modal.open({
templateUrl: ‘editModal.html’,
controller: [‘$modalInstance’, ‘PersonSchema’, ‘grid’, ‘row’, ModalInstanceCtrl],
//controllerAs: ‘vm’,
resolve: {
grid: function () { return grid; },
row: function () { return row; }
}
});
}
return service;
}]);
——–
edit modal

Edit Row

Save
Cancel

—–
edit button

</div

]]>
By: Jayesh https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-236 Thu, 05 May 2016 12:12:00 +0000 https://brianhann.com/?p=162#comment-236 Great Article. One small requirement, How I can keep the Grid in Edit mode. I want all cell which are editable to be always open and doesn’t open in double click or single click

]]>
By: ravgup https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-224 Wed, 16 Mar 2016 15:13:00 +0000 https://brianhann.com/?p=162#comment-224 Hi Brian, I have implemented the model window with ui-grid. I want to check, can we add a ADD NEW functionality in this using the modal popup?

]]>
By: Roshni Shankhwar https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-209 Wed, 10 Feb 2016 04:44:00 +0000 https://brianhann.com/?p=162#comment-209 Hi Sir!
I implemented this row editor and my model window have a dropdown on selecting options of dropdown menu data of schema form has to be change according to corresponding row’s entry in DB.
Is it possible? thanks in advance!:)

]]>
By: FlipO https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-200 Mon, 25 Jan 2016 12:21:00 +0000 https://brianhann.com/?p=162#comment-200 Thanks a lot Brian! Magnificent explanation that works!

But I want to display the form into a seperate div near the grid, and not into a modal…
The div is with id=”detail” ng-include=” ‘service-edit.html’ “…
How can I get the data from the function editRow(grid, row) with the same result as $modal.open()?
$uibModal’s open function is not an option for me…

Thx a lot!

]]>
By: gaurav https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-191 Fri, 08 Jan 2016 10:01:00 +0000 https://brianhann.com/?p=162#comment-191 hi brian,
i have to populate one field as dropdown list in model popup so how it is possible?

]]>
By: ian macdonald https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-189 Sun, 03 Jan 2016 13:49:00 +0000 https://brianhann.com/?p=162#comment-189 hi Brian, I’m new to Angular/javascript and I found this most useful thank you. I do find the code a little hard to understand, especially the injections, but this likely to my little understanding of the language. After I save the modal, I want to update a database. I have a $resource defined on the main controller, how can I pass this through to the modal?

Many thanks in advanced!

]]>
By: Webia1 https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-186 Tue, 22 Dec 2015 09:04:00 +0000 https://brianhann.com/?p=162#comment-186 First of all many thanks for your effords, great job! If you would use the standard angular approach (e.g. here https://github.com/johnpapa/angular-styleguide) your code would be easier to understand, I think. I could not comprehend, why you avoid to use $scope in your code.

]]>
By: Ravikumar K https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-163 Fri, 30 Oct 2015 06:12:00 +0000 https://brianhann.com/?p=162#comment-163 Hi Brian, this helped me a lot. thank you so much.

But I am facing issue in saving data to grid from the modal.

please check this plunker –> http://plnkr.co/edit/ss5pAvAssZoAiYhDM8YP?p=preview

Here I have to save comments to the grid and the same should go and save to database.

Actually the data has to fetch from database each time, but the one who edits it he has to see his comments right a way. for others it will fetch from database. I tried with your code but i need custom model like how it is in plunker. can you help me in resolving this.

Thanks 🙂

]]>
By: Razvan https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-119 Wed, 19 Aug 2015 05:41:00 +0000 https://brianhann.com/?p=162#comment-119 Hi Brian, thanks for the reply. I use Angular 1.4.3, validation is set using $validators just like Angular Schema Form documentation ( https://github.com/Textalk/angular-schema-form/blob/development/docs/index.md#using-ngmodelcontroller )

Inside RowEditCtrl I’ve tried triggering $scope.$broadcast(‘schemaFormValidate’); on $modalInstance.opened or on $modalInstance.rendered and $scope.$on(‘sf-render-finished’) but without success. I ended up using a custom method in the controller that takes each field in the controller and triggers $scope[formname][fieldname].$$parseAndValidate();. This is how I trigger validation on modal open and onSubmit:

$modalInstance.opened.then(function(){
$scope.$broadcast(‘schemaFormValidate’);
$scope.$on(‘sf-render-finished’, function(event, mass) {
// console.log(mass);
$timeout(function() {
validate();
$scope.$broadcast(‘schemaFormValidate’);
}, 1);
});
});

vm.onSubmit = function(editForm) {
// First we broadcast an event so all fields validate themselves
validate();
$scope.$broadcast(‘schemaFormValidate’);
// Then we check if the form is valid
if (editForm.$valid) {
//… do whatever you need to do with your data.

row.entity = angular.extend(row.entity, vm.entity);
vm.grid.api.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
$modalInstance.close(row.entity);
}
}

//validate each form field
function validate(){

angular.forEach(vm.entity, function(value, key){
if($scope.hasOwnProperty(‘editRowForm’) && $scope.editRowForm.hasOwnProperty(key)) {
$scope.editRowForm[key].$$parseAndValidate();

}
});
}

]]>
By: Brian Hann https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-117 Tue, 18 Aug 2015 17:25:00 +0000 https://brianhann.com/?p=162#comment-117 Hi, Razvan. Thanks! Glad it’s helped you.

I think the solution depends on how you’re doing validation. You may need to manually trigger the validation to run after the modal is opened. Are you using Angular’s built-in form validation? If so, which version of Angular?

]]>
By: Razvan https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-109 Thu, 06 Aug 2015 10:56:00 +0000 https://brianhann.com/?p=162#comment-109 Hi Brian, great job! Your example helped me allot. I attached some validation to the schema which triggers when one changes fields in the form, but I need for validation to be triggered when when modal is displayed and fields that are not valid to be marked with ‘has-error’. Can you give me an idea or a hint to help me solve my problem?

]]>
By: Brian Hann https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-77 Thu, 25 Jun 2015 21:49:00 +0000 https://brianhann.com/?p=162#comment-77 Anton, glad you liked it! If you’re wanting to have the modal overlay the grid like this one, you could have a similar setup but use a different function for saving of course. And you could initiate the modal from the grid menu. Check out this tutorial for creating custom menu items: http://ui-grid.info/docs/#/tutorial/121_grid_menu

]]>
By: Anton Bakels https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-63 Wed, 17 Jun 2015 08:06:00 +0000 https://brianhann.com/?p=162#comment-63 Thanks a lot for the article! Great work!
I am trying to have the same “row modal editor UI” for creating a new record in the existing table. Do you have any ideas how to create this extra option?

]]>
By: Arjan https://brianhann.com/create-a-modal-row-editor-for-ui-grid-in-minutes/#comment-53 Wed, 10 Jun 2015 13:46:00 +0000 https://brianhann.com/?p=162#comment-53 Thanks

]]>