Hi,
Is there a way to stop the whole row in a gridfield to link to the edit page and have only the edit button link to the edit page?
i have a file link in the row and if you click on it it will open the pdf but also the edit page.
Thanks
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi,
Is there a way to stop the whole row in a gridfield to link to the edit page and have only the edit button link to the edit page?
i have a file link in the row and if you click on it it will open the pdf but also the edit page.
Thanks
Hi, you need to comment some lines in javascript.
You can find it here: framework/javascript/GridField.js
Find this code at line 116:
$('.ss-gridfield .ss-gridfield-item').entwine({
onclick: function(e) {
if($(e.target).closest('.action').length) {
this._super(e);
return false;
}
var editLink = this.find('.edit-link');
if(editLink.length) this.getGridField().showDetailView(editLink.prop('href'));
},
onmouseover: function() {
if(this.find('.edit-link').length) this.css('cursor', 'pointer');
},
onmouseout: function() {
this.css('cursor', 'default');
}
});
$('.ss-gridfield .ss-gridfield-item').entwine({
/*onclick: function(e) {
if($(e.target).closest('.action').length) {
this._super(e);
return false;
}
var editLink = this.find('.edit-link');
if(editLink.length) this.getGridField().showDetailView(editLink.prop('href'));
},*/
onmouseover: function() {
if(this.find('.edit-link').length) this.css('cursor', 'pointer');
},
onmouseout: function() {
this.css('cursor', 'default');
}
});
A bit late, but just in case someone needs this:
I needed to insert a target="_blank" custom link to a pdf file into the GridField rows, which worked well, but in the background ModelAdmin still went on to display the DetailForm. Triggered by the Johnny9 answer above, I did this:
config.yml
LeftAndMain:
extra_requirements_javascript:
- mymodule/javascript/myfile.js
mymodule/javascript/myfile.js
(function($){
$.entwine('ss', function($) {
$('.ss-gridfield .ss-gridfield-item .showPDFLink').entwine({
onclick: function(e) {
e.stopPropagation();
}
});
});
})(jQuery);
where showPDFLink is the class of the custom link