angular service for centralizing common grid functions The 2019 Stack Overflow Developer Survey Results Are InAngularJS bookviewer directive written with Typescript and Angular-ui bootstrapReusable REST service class for Angular2 in TypeScriptModal component in Angular 2Vehicle price calculation Angular serviceAngular + Redux app organization and initialization: transfer from a PHP-driven websiteCalling Service and Initiate under ngOnOnit (not in Constructor) Hook in Angular4Build dynamic HTTP service with AngularAngular2 “Logged In State Watcher”Search Result with infinite scroll React componentOptimistic validation on tab change
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
Pokemon Turn Based battle (Python)
Why “相同意思的词” is called “同义词” instead of "同意词"?
How to obtain a position of last non-zero element
Can a flute soloist sit?
What do I do when my TA workload is more than expected?
Why didn't the Event Horizon Telescope team mention Sagittarius A*?
Is Cinnamon a desktop environment or a window manager? (Or both?)
How to type a long/em dash `—`
Relationship between Gromov-Witten and Taubes' Gromov invariant
What do these terms in Caesar's Gallic wars mean?
If a sorcerer casts the Banishment spell on a PC while in Avernus, does the PC return to their home plane?
How much of the clove should I use when using big garlic heads?
What is the motivation for a law requiring 2 parties to consent for recording a conversation
How to charge AirPods to keep battery healthy?
Cooking pasta in a water boiler
Worn-tile Scrabble
Is it possible for absolutely everyone to attain enlightenment?
If I can cast sorceries at instant speed, can I use sorcery-speed activated abilities at instant speed?
Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Why not take a picture of a closer black hole?
Slides for 30 min~1 hr Skype tenure track application interview
How to translate "being like"?
angular service for centralizing common grid functions
The 2019 Stack Overflow Developer Survey Results Are InAngularJS bookviewer directive written with Typescript and Angular-ui bootstrapReusable REST service class for Angular2 in TypeScriptModal component in Angular 2Vehicle price calculation Angular serviceAngular + Redux app organization and initialization: transfer from a PHP-driven websiteCalling Service and Initiate under ngOnOnit (not in Constructor) Hook in Angular4Build dynamic HTTP service with AngularAngular2 “Logged In State Watcher”Search Result with infinite scroll React componentOptimistic validation on tab change
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks for the sort, filter, group functions of the grid. 90% of the grids I have are a very simple CRUD grid with next to no validation or business logic involved.
As a result, I have to write the following code (Typescript) over and over for each grid:
public initData(): void
this.gridData = process(this.data, this.gridState);
public onStateChange(state: DataStateChangeEvent): void
state.group.map(group => (group.aggregates = this.aggregates));
this.gridState = state;
this.gridData = process(this.data, this.gridState);
public groupChange(grp: GroupDescriptor[]): void
this.groups = grp;
this.gridData = process(this.data, this.gridState);
public sortChange(srt: SortDescriptor[]): void
this.sort = srt;
this.gridData = process(this.data, this.gridState);
public filterChange(fltr: CompositeFilterDescriptor): void
this.filter = fltr;
this.gridData = process(filterBy(this.data, this.filter),
group: this.groups,
sort: this.sort
);
this is obviously in the component class behind each grid.
What I am wondering is, Can I move the functions to a service so that I don't have to rewrite them for each component? Additionally, should I create them as static so that there is only one or should I instantiate a new "service" for each component?
Just wondering what others think about this
Thanks
typescript angular-2+
$endgroup$
add a comment |
$begingroup$
I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks for the sort, filter, group functions of the grid. 90% of the grids I have are a very simple CRUD grid with next to no validation or business logic involved.
As a result, I have to write the following code (Typescript) over and over for each grid:
public initData(): void
this.gridData = process(this.data, this.gridState);
public onStateChange(state: DataStateChangeEvent): void
state.group.map(group => (group.aggregates = this.aggregates));
this.gridState = state;
this.gridData = process(this.data, this.gridState);
public groupChange(grp: GroupDescriptor[]): void
this.groups = grp;
this.gridData = process(this.data, this.gridState);
public sortChange(srt: SortDescriptor[]): void
this.sort = srt;
this.gridData = process(this.data, this.gridState);
public filterChange(fltr: CompositeFilterDescriptor): void
this.filter = fltr;
this.gridData = process(filterBy(this.data, this.filter),
group: this.groups,
sort: this.sort
);
this is obviously in the component class behind each grid.
What I am wondering is, Can I move the functions to a service so that I don't have to rewrite them for each component? Additionally, should I create them as static so that there is only one or should I instantiate a new "service" for each component?
Just wondering what others think about this
Thanks
typescript angular-2+
$endgroup$
add a comment |
$begingroup$
I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks for the sort, filter, group functions of the grid. 90% of the grids I have are a very simple CRUD grid with next to no validation or business logic involved.
As a result, I have to write the following code (Typescript) over and over for each grid:
public initData(): void
this.gridData = process(this.data, this.gridState);
public onStateChange(state: DataStateChangeEvent): void
state.group.map(group => (group.aggregates = this.aggregates));
this.gridState = state;
this.gridData = process(this.data, this.gridState);
public groupChange(grp: GroupDescriptor[]): void
this.groups = grp;
this.gridData = process(this.data, this.gridState);
public sortChange(srt: SortDescriptor[]): void
this.sort = srt;
this.gridData = process(this.data, this.gridState);
public filterChange(fltr: CompositeFilterDescriptor): void
this.filter = fltr;
this.gridData = process(filterBy(this.data, this.filter),
group: this.groups,
sort: this.sort
);
this is obviously in the component class behind each grid.
What I am wondering is, Can I move the functions to a service so that I don't have to rewrite them for each component? Additionally, should I create them as static so that there is only one or should I instantiate a new "service" for each component?
Just wondering what others think about this
Thanks
typescript angular-2+
$endgroup$
I have an angular 7 app that is data focused and as a result has dozens of grids. These grids are from the Kendo UI for ANgular component library made by Telerik. These grid components expose hooks for the sort, filter, group functions of the grid. 90% of the grids I have are a very simple CRUD grid with next to no validation or business logic involved.
As a result, I have to write the following code (Typescript) over and over for each grid:
public initData(): void
this.gridData = process(this.data, this.gridState);
public onStateChange(state: DataStateChangeEvent): void
state.group.map(group => (group.aggregates = this.aggregates));
this.gridState = state;
this.gridData = process(this.data, this.gridState);
public groupChange(grp: GroupDescriptor[]): void
this.groups = grp;
this.gridData = process(this.data, this.gridState);
public sortChange(srt: SortDescriptor[]): void
this.sort = srt;
this.gridData = process(this.data, this.gridState);
public filterChange(fltr: CompositeFilterDescriptor): void
this.filter = fltr;
this.gridData = process(filterBy(this.data, this.filter),
group: this.groups,
sort: this.sort
);
this is obviously in the component class behind each grid.
What I am wondering is, Can I move the functions to a service so that I don't have to rewrite them for each component? Additionally, should I create them as static so that there is only one or should I instantiate a new "service" for each component?
Just wondering what others think about this
Thanks
typescript angular-2+
typescript angular-2+
asked 3 hours ago
J KingJ King
1455
1455
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");
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: "196"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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%2fcodereview.stackexchange.com%2fquestions%2f217286%2fangular-service-for-centralizing-common-grid-functions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Code Review Stack Exchange!
- 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.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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%2fcodereview.stackexchange.com%2fquestions%2f217286%2fangular-service-for-centralizing-common-grid-functions%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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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