1

这是我的场景。我有一个只有 1 个可编辑字段的 radgrid(其余字段设置为只读),因此当它处于编辑模式时,会显示一个允许的编辑。但是当我尝试完成插入(添加)时,它只显示插入的一个字段,但我也需要所有其他字段。

如何在 ItemCommand 事件期间以编程方式切换只读属性而不导致重新绑定?

4

1 回答 1

1

对于任何感兴趣的人,这是解决方案(无需使用自定义模板)。这会将列的原始状态从只读更改为可编辑状态。

protected void rgvDepts_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName.Equals(RadGrid.InitInsertCommandName))
        {
            GridCommandItem item = e.Item as GridCommandItem;
            GridTableView masterTable = item.OwnerTableView;
            GridBoundColumn gbc = null;
            if (item != null && masterTable != null)
            {                    
                gbc = (GridBoundColumn)masterTable.GetColumn("LIFNR");
                if (gbc != null)
                {
                    gbc.ReadOnly = false;
                    gbc.Visible = true;                       
                }
            }
        }
    }
于 2012-11-02T14:02:39.213 回答