telerik mvc grid 访问单元格数据以启用列。命令

发布于 2024-10-08 09:24:46 字数 414 浏览 0 评论 0原文

我似乎找不到一种方法来引用网格中列中的值,在我的例子中它是 StatusId。根据该行中的单元格值,对于 StatusId,我需要向方法“.Visible(???)”返回 true 或 false。很高兴能在在线文档中找到答案,但我一直没能找到。我很难相信我会是第一个需要此功能的人。

我将非常感谢任何帮助,因为 Telerik 论坛中没有人知道。

.Columns(columns => {
    columns.Command(commands => { 
    commands.Edit().ButtonType(ButtonType); 
    commands.Delete().ButtonType(ButtonType); 
}).Width(90).Visible(???);

谢谢! AZee

I can't seem to find a way to reference the value in a column in the grid, in my case it is the StatusId. Based on the cell value in this row, for the StatusId, I need to return a true or false to the method ".Visible(???)". It would be nice to find the answer in the documentation online but I haven't been able to. I find it hard to believe that I would be the first person who ever needed this functionality.

I would be most appreciative of any assistance since no one in the telerik forums know.

.Columns(columns => {
    columns.Command(commands => { 
    commands.Edit().ButtonType(ButtonType); 
    commands.Delete().ButtonType(ButtonType); 
}).Width(90).Visible(???);

Thanks!
AZee

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情妓 2024-10-15 09:24:46

Visible 设置控制列的可见性。如果设置为 false 该列根本不会呈现。您可以尝试使用CellAction

.CellAction(cell =>
    {
        if (cell.Column.Title == "Commands")
        {
            if (cell.DataItem.StatusId > 0) //check whether to hide the cell
            {
                cell.HtmlAttributes["style"] = "visibility:hidden";
            }
        }

    })

The Visible setting controls the visibility of the column. If set to false the column will not render at all. You can try using the CellAction:

.CellAction(cell =>
    {
        if (cell.Column.Title == "Commands")
        {
            if (cell.DataItem.StatusId > 0) //check whether to hide the cell
            {
                cell.HtmlAttributes["style"] = "visibility:hidden";
            }
        }

    })
甜警司 2024-10-15 09:24:46

上述解决方案不适用于 Ajax 绑定 ....例如,如果我想以红色显示特定单元格的文本颜色 .." 即 Cell_Text="In Error",当网格第一次加载时,则此解决方案适用,但是当我在上述网格上应用一些 Ajax 操作(例如 Filtering )时,我的 Cell_Text 再次变回正常文本颜色....您是否有针对我的特定场景的其他代码

Above solution doesnt work with Ajax Binding ....For example if I want to show a perticular Cell's text Color in Red .." i.e. Cell_Text="In Error", when the Grid loads for the 1st time then this solution becomes applicable but when I apply some Ajax Actions on the said Grid like Filtering , then my Cell_Text again changes back to its normal text color .... Do you have any other codes for my perticular scenario

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文