DevExpress MVC GridView:使用 DetailRowGetButtonVisibility
是否可以在 ASP.NET MVC 中使用 RowGetButtonVisibility 事件? 在“正常”ASP.NET DevExpress 中,使用如下描述:
我希望有可能显示/隐藏 GridView 中的详细信息按钮。
有什么想法可以做到这一点吗?
像这样的东西不起作用:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<FOO>" %>
<%
Html.DevExpress().GridView(settings =>
{
settings.Name = "resultsTable";
settings.KeyFieldName = "ResultId";
settings.CallbackRouteValues = new { Controller = "Results", Action = "ResultsPartial" };
settings.Width = Unit.Percentage(100);
settings.Height = Unit.Percentage(100);
//...
settings.PreRender = (sender, e) =>
{
MVCxGridView grid = (MVCxGridView)sender;
grid.DetailRowGetButtonVisibility += (s_, e_) =>
{
if (some_condition == true)
e_.ButtonState = GridViewDetailRowButtonState.Hidden;
};
};
})
.Bind(Model.Results)
.Render();
Is it possible to use the event RowGetButtonVisibility in ASP.NET MVC?
In "normal" ASP.NET DevExpress is using this like described here:
I want to have the possibility to show/hide the detail button within the GridView.
Any ideas to do this?
Something like this is not working:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<FOO>" %>
<%
Html.DevExpress().GridView(settings =>
{
settings.Name = "resultsTable";
settings.KeyFieldName = "ResultId";
settings.CallbackRouteValues = new { Controller = "Results", Action = "ResultsPartial" };
settings.Width = Unit.Percentage(100);
settings.Height = Unit.Percentage(100);
//...
settings.PreRender = (sender, e) =>
{
MVCxGridView grid = (MVCxGridView)sender;
grid.DetailRowGetButtonVisibility += (s_, e_) =>
{
if (some_condition == true)
e_.ButtonState = GridViewDetailRowButtonState.Hidden;
};
};
})
.Bind(Model.Results)
.Render();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我会在
SetDataItemTemplateContent
中使用纯 html 按钮。我做了类似的事情,使用可以扩展的简单
if
来处理链接的输出。我想它也应该适合你。在此 html 代码中,您可以附加对所需回调操作的调用。如果我没记错的话,应该是这样的
希望有帮助。
I think I will go with pure html button inside the
SetDataItemTemplateContent
.I did something like that to handle the output of a link using a simple
if
that you can extend. I guess it should work also for you.Inside this html code you could attach a call to the callback action you need. If i remember right, it should be something like that
Hope it helps.
我按照 DevExpress 论坛中所述解决了我的问题:
http:// Community.devexpress.com/forums/p/105806/358003.aspx#358003
我第一次尝试附加事件是正确的,但在 PreRender 上却不是。 DataBound 是正确使用的事件。
I solved my problem as described in the DevExpress-Forum here:
http://community.devexpress.com/forums/p/105806/358003.aspx#358003
My first try with attaching to the event was right, but not at PreRender. DataBound is the right event to use.