Hiding create edit delete buttons based on user priveleges #1486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I was developing a web app in MVC asp.net and I wanted to show/hide buttons based on a user's priveleges. The buttons access/priveleges for users are defined in a database table.
As per HIK, if we don't assign a value for createAction, it will be hidden. This is ok for create button. However, edit and delete buttons do not hide and hence a fix is required.
For below code, all 3 buttons sould hide
actions: {
'createAction': '',
'deleteAction': '',
'updateAction': ''
},
In my opinion, the shortest possible fix is to add one condition. Change required in file jquery.jtable.js version jTable 2.4.0:
in line 2535 - if updateaction is blank then no need to create empty header
if (this.options.actions.updateAction != undefined && this.options.actions.updateAction != '')
in line 2545 - if updateaction is blank then no need to create the button
if (self.options.actions.updateAction != undefined && self.options.actions.updateAction != '')
in line 3011 - if deleteaction is blank then no need to create empty header
if (this.options.actions.deleteAction != undefined && this.options.actions.deleteAction != '') {
in line 3022 - if deleteaction is blank then no need to create the buttons
if (self.options.actions.deleteAction != undefined && self.options.actions.deleteAction != '') {
Thanks.