Grid: how to prevent the deletion action

36 views
Skip to first unread message

Jorge Segura

unread,
May 14, 2013, 5:18:30 PM5/14/13
to net...@googlegroups.com
Hi, is it posible to prevent the deletion action in the grid view component? How can I achieve this behavior?

Best regards.

Max Gorin

unread,
May 14, 2013, 6:57:03 PM5/14/13
to net...@googlegroups.com
Did you consult the docs?
http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Grid

--
Max Gorin
@nomadcoder
author of @netzke




Jorge Segura

unread,
May 14, 2013, 8:56:50 PM5/14/13
to net...@googlegroups.com
Thanks for answering. I read the docs and I overwrite the following methods by comment the :del action from the context_menu and the bbar.
It works, thanks.

def default_context_menu
res = config[:enable_edit_inline] || config[:enable_edit_in_form] ? [:edit] : []
# res << :del if !config[:read_only]
res << "-" << :edit_in_form if config[:enable_edit_in_form] && config[:enable_edit_inline]
end

def default_bbar
res = config[:enable_edit_inline] || config[:enable_edit_in_form] ? %w{ add edit }.map(&:to_sym) : []
res << :apply if config[:enable_edit_inline]
# res << :del
res << "-" << :add_in_form << :edit_in_form if config[:enable_edit_inline] && config[:enable_edit_in_form]
res << "-" << :search if config[:enable_extended_search]
res
end

Max Gorin

unread,
May 16, 2013, 2:43:05 AM5/16/13
to net...@googlegroups.com
A simpler way is to exclude an action from a component is to override
it, setting +excluded+ to +true+:

action :del do |c|
super c
c.excluded = true
end

(the corresponding docs:
http://rdoc.info/github/netzke/netzke-core/Netzke/Core/Actions)

But you should also set "prohibit_delete" to true in your grid to make
it secure on the server side:

class YourGrid < Netzke::Basepack::Grid
def configure(c)
super
c.prohibit_delete = true
end
end

(the corresponding docs:
http://rdoc.info/github/netzke/netzke-basepack/Netzke/Basepack/Grid)
Reply all
Reply to author
Forward
0 new messages