ag-grid + angularJS header and cells editable by the user
I just start using the ag-grid
library with angularJS
to display some tabular data in my application. The thing now is that I want the user to be able to alter the header value of each column like as he/she can edit the cells within a column when we enable the editable
attribute. While searching for a solution I realized that there is no default way to turn the header into an editable element. So I was wondering which are my alternatives.
One thought of mine was to add to each header an edit button and when clicked a modal window to pop up with the corresponding input fields of the header and its column's cell values. In this case, the editable
attribute is not going to be used because the edit of the cells will be conducted within the modal. Something like that but instead for the row, the button should be in each header.
So which are the ways that I can achieve something like that? I read about header template but couldn't really found any straightforward way to approach it.
Any ideas/hints or other alternatives are welcome.
angularjs ag-grid
add a comment |
I just start using the ag-grid
library with angularJS
to display some tabular data in my application. The thing now is that I want the user to be able to alter the header value of each column like as he/she can edit the cells within a column when we enable the editable
attribute. While searching for a solution I realized that there is no default way to turn the header into an editable element. So I was wondering which are my alternatives.
One thought of mine was to add to each header an edit button and when clicked a modal window to pop up with the corresponding input fields of the header and its column's cell values. In this case, the editable
attribute is not going to be used because the edit of the cells will be conducted within the modal. Something like that but instead for the row, the button should be in each header.
So which are the ways that I can achieve something like that? I read about header template but couldn't really found any straightforward way to approach it.
Any ideas/hints or other alternatives are welcome.
angularjs ag-grid
What you are trying to achieve? Header - just a name of the field in data-object which is passed by you viarowData
orsetData
. For what you need to modify a header? should it change the structure then?
– un.spike
Nov 19 '18 at 20:10
I want, the user to be able to change the structure. Let's say for example that each row describes a linear model. The first column describes the first parameter, the second column the second parameter etc. So I want the user to be able to set the name of that parameter as well as the value of it for each model.
– J. Doe
Nov 19 '18 at 20:52
have you thought about how you will update the structure inside ag-grid? I mean, ok, the case is clear for now, but you wanna to combine it in onecomponent
and actually I don't think its good idea.
– un.spike
Nov 19 '18 at 21:05
No. I didn't thought it and that's why I asked here. Maybe there was something that I missed from the documentation. Combine what with a component? How do you mean that?
– J. Doe
Nov 19 '18 at 21:36
add a comment |
I just start using the ag-grid
library with angularJS
to display some tabular data in my application. The thing now is that I want the user to be able to alter the header value of each column like as he/she can edit the cells within a column when we enable the editable
attribute. While searching for a solution I realized that there is no default way to turn the header into an editable element. So I was wondering which are my alternatives.
One thought of mine was to add to each header an edit button and when clicked a modal window to pop up with the corresponding input fields of the header and its column's cell values. In this case, the editable
attribute is not going to be used because the edit of the cells will be conducted within the modal. Something like that but instead for the row, the button should be in each header.
So which are the ways that I can achieve something like that? I read about header template but couldn't really found any straightforward way to approach it.
Any ideas/hints or other alternatives are welcome.
angularjs ag-grid
I just start using the ag-grid
library with angularJS
to display some tabular data in my application. The thing now is that I want the user to be able to alter the header value of each column like as he/she can edit the cells within a column when we enable the editable
attribute. While searching for a solution I realized that there is no default way to turn the header into an editable element. So I was wondering which are my alternatives.
One thought of mine was to add to each header an edit button and when clicked a modal window to pop up with the corresponding input fields of the header and its column's cell values. In this case, the editable
attribute is not going to be used because the edit of the cells will be conducted within the modal. Something like that but instead for the row, the button should be in each header.
So which are the ways that I can achieve something like that? I read about header template but couldn't really found any straightforward way to approach it.
Any ideas/hints or other alternatives are welcome.
angularjs ag-grid
angularjs ag-grid
asked Nov 19 '18 at 19:41
J. DoeJ. Doe
31517
31517
What you are trying to achieve? Header - just a name of the field in data-object which is passed by you viarowData
orsetData
. For what you need to modify a header? should it change the structure then?
– un.spike
Nov 19 '18 at 20:10
I want, the user to be able to change the structure. Let's say for example that each row describes a linear model. The first column describes the first parameter, the second column the second parameter etc. So I want the user to be able to set the name of that parameter as well as the value of it for each model.
– J. Doe
Nov 19 '18 at 20:52
have you thought about how you will update the structure inside ag-grid? I mean, ok, the case is clear for now, but you wanna to combine it in onecomponent
and actually I don't think its good idea.
– un.spike
Nov 19 '18 at 21:05
No. I didn't thought it and that's why I asked here. Maybe there was something that I missed from the documentation. Combine what with a component? How do you mean that?
– J. Doe
Nov 19 '18 at 21:36
add a comment |
What you are trying to achieve? Header - just a name of the field in data-object which is passed by you viarowData
orsetData
. For what you need to modify a header? should it change the structure then?
– un.spike
Nov 19 '18 at 20:10
I want, the user to be able to change the structure. Let's say for example that each row describes a linear model. The first column describes the first parameter, the second column the second parameter etc. So I want the user to be able to set the name of that parameter as well as the value of it for each model.
– J. Doe
Nov 19 '18 at 20:52
have you thought about how you will update the structure inside ag-grid? I mean, ok, the case is clear for now, but you wanna to combine it in onecomponent
and actually I don't think its good idea.
– un.spike
Nov 19 '18 at 21:05
No. I didn't thought it and that's why I asked here. Maybe there was something that I missed from the documentation. Combine what with a component? How do you mean that?
– J. Doe
Nov 19 '18 at 21:36
What you are trying to achieve? Header - just a name of the field in data-object which is passed by you via
rowData
or setData
. For what you need to modify a header? should it change the structure then?– un.spike
Nov 19 '18 at 20:10
What you are trying to achieve? Header - just a name of the field in data-object which is passed by you via
rowData
or setData
. For what you need to modify a header? should it change the structure then?– un.spike
Nov 19 '18 at 20:10
I want, the user to be able to change the structure. Let's say for example that each row describes a linear model. The first column describes the first parameter, the second column the second parameter etc. So I want the user to be able to set the name of that parameter as well as the value of it for each model.
– J. Doe
Nov 19 '18 at 20:52
I want, the user to be able to change the structure. Let's say for example that each row describes a linear model. The first column describes the first parameter, the second column the second parameter etc. So I want the user to be able to set the name of that parameter as well as the value of it for each model.
– J. Doe
Nov 19 '18 at 20:52
have you thought about how you will update the structure inside ag-grid? I mean, ok, the case is clear for now, but you wanna to combine it in one
component
and actually I don't think its good idea.– un.spike
Nov 19 '18 at 21:05
have you thought about how you will update the structure inside ag-grid? I mean, ok, the case is clear for now, but you wanna to combine it in one
component
and actually I don't think its good idea.– un.spike
Nov 19 '18 at 21:05
No. I didn't thought it and that's why I asked here. Maybe there was something that I missed from the documentation. Combine what with a component? How do you mean that?
– J. Doe
Nov 19 '18 at 21:36
No. I didn't thought it and that's why I asked here. Maybe there was something that I missed from the documentation. Combine what with a component? How do you mean that?
– J. Doe
Nov 19 '18 at 21:36
add a comment |
1 Answer
1
active
oldest
votes
Make a service which have an array as DataSet of your grid, and provide it with handlers for the events of a CRUD in the same service. Inject the service into the controller of your modal and view of the grid. After that, call the object gridDataSetadd,remove,update who is in the service, then $digest do the rest of the work once DataSet will be modified.
UPDATE, answering the comment
Inject your service into your controller:
For .ts
static $inject = ['$scope','YourService'];
constructor($scope, userService: YourService) {
this.userService.getSomething();
}
For .js
.controller('YourCtrl', ['$scope', 'YourService', function ($scope, YourService) {
$scope.someVar = YourService.someVar;
}])
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
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%2f53381552%2fag-grid-angularjs-header-and-cells-editable-by-the-user%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
Make a service which have an array as DataSet of your grid, and provide it with handlers for the events of a CRUD in the same service. Inject the service into the controller of your modal and view of the grid. After that, call the object gridDataSetadd,remove,update who is in the service, then $digest do the rest of the work once DataSet will be modified.
UPDATE, answering the comment
Inject your service into your controller:
For .ts
static $inject = ['$scope','YourService'];
constructor($scope, userService: YourService) {
this.userService.getSomething();
}
For .js
.controller('YourCtrl', ['$scope', 'YourService', function ($scope, YourService) {
$scope.someVar = YourService.someVar;
}])
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
add a comment |
Make a service which have an array as DataSet of your grid, and provide it with handlers for the events of a CRUD in the same service. Inject the service into the controller of your modal and view of the grid. After that, call the object gridDataSetadd,remove,update who is in the service, then $digest do the rest of the work once DataSet will be modified.
UPDATE, answering the comment
Inject your service into your controller:
For .ts
static $inject = ['$scope','YourService'];
constructor($scope, userService: YourService) {
this.userService.getSomething();
}
For .js
.controller('YourCtrl', ['$scope', 'YourService', function ($scope, YourService) {
$scope.someVar = YourService.someVar;
}])
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
add a comment |
Make a service which have an array as DataSet of your grid, and provide it with handlers for the events of a CRUD in the same service. Inject the service into the controller of your modal and view of the grid. After that, call the object gridDataSetadd,remove,update who is in the service, then $digest do the rest of the work once DataSet will be modified.
UPDATE, answering the comment
Inject your service into your controller:
For .ts
static $inject = ['$scope','YourService'];
constructor($scope, userService: YourService) {
this.userService.getSomething();
}
For .js
.controller('YourCtrl', ['$scope', 'YourService', function ($scope, YourService) {
$scope.someVar = YourService.someVar;
}])
Make a service which have an array as DataSet of your grid, and provide it with handlers for the events of a CRUD in the same service. Inject the service into the controller of your modal and view of the grid. After that, call the object gridDataSetadd,remove,update who is in the service, then $digest do the rest of the work once DataSet will be modified.
UPDATE, answering the comment
Inject your service into your controller:
For .ts
static $inject = ['$scope','YourService'];
constructor($scope, userService: YourService) {
this.userService.getSomething();
}
For .js
.controller('YourCtrl', ['$scope', 'YourService', function ($scope, YourService) {
$scope.someVar = YourService.someVar;
}])
edited Nov 20 '18 at 17:39
answered Nov 19 '18 at 22:52
SiegSieg
336211
336211
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
add a comment |
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
Excuse, but how am I going to inject the service to the view of the grid? Can you give me an example?
– J. Doe
Nov 20 '18 at 7:06
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53381552%2fag-grid-angularjs-header-and-cells-editable-by-the-user%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
What you are trying to achieve? Header - just a name of the field in data-object which is passed by you via
rowData
orsetData
. For what you need to modify a header? should it change the structure then?– un.spike
Nov 19 '18 at 20:10
I want, the user to be able to change the structure. Let's say for example that each row describes a linear model. The first column describes the first parameter, the second column the second parameter etc. So I want the user to be able to set the name of that parameter as well as the value of it for each model.
– J. Doe
Nov 19 '18 at 20:52
have you thought about how you will update the structure inside ag-grid? I mean, ok, the case is clear for now, but you wanna to combine it in one
component
and actually I don't think its good idea.– un.spike
Nov 19 '18 at 21:05
No. I didn't thought it and that's why I asked here. Maybe there was something that I missed from the documentation. Combine what with a component? How do you mean that?
– J. Doe
Nov 19 '18 at 21:36