radgrid控件就编辑栏不可见 [英] RadGrid make field invisible on Edit

查看:250
本文介绍了radgrid控件就编辑栏不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < Telerik的:radgrid控件=服务器ID =rdReport的AutoGenerateColumns =false的AllowPaging =真皮=新城OnItemCommand =ItemCommandOnItemDataBound = rdReport_ItemDataBound在preRender =rdReport_ preRender的DataSourceID =FountainSourceAllowAutomaticUpdates =真AllowAutomaticDeletes =真>
    < MasterTableView的DataKeyNames =IDCommandItemDisplay =无>
        <柱体和GT;
            < Telerik的:GridEditCommandColumn按钮类型=ImageButton的/>
            < Telerik的:GridBoundColumn数据字段=LOCNAME的HeaderText =位置只读=真/>
            <
            < Telerik的:GridBoundColumn数据字段=Field1Value的HeaderText =自定义字段1/>
            < Telerik的:GridBoundColumn数据字段=Field2Value的HeaderText =自定义字段2/>
            < Telerik的:GridBoundColumn数据字段=Field3Value的HeaderText =自定义字段3/>            < Telerik的:GridButtonColumn ConfirmText =删除? ConfirmDialogType =RadWindow
                ConfirmTitle =删除按钮类型=的ImageButton的CommandName =删除/>
        < /专栏>
        < EditFormSettings>
            < EditColumn按钮类型=ImageButton的/>
        < / EditFormSettings>
    < / MasterTableView>
    < PagerStyle模式=下一步prevAndNumeric/>
< / Telerik的:radgrid控件>

在编辑,我喜欢做一个现场看不见。
我使用下面的code这工作,但要检查,看它是否是最好的做法:

 保护无效rdReport_ItemDataBound(对象发件人,GridItemEventArgs E)
{
    //编辑模式
    如果((e.Item是GridEditFormItem)及及(e.Item.IsInEditMode))
    {
        GridEditFormItem fndColumn =(GridEditFormItem)e.Item;
        。fnColumn [Field1Value] = Parent.Visible虚假的;
    }
}


解决方案

这是你所提供的解决方案是完美的,但它会很好,如果你也将在每列中添加UniqueName属性。如果我们不指定UniqueName比它考虑数据字段值UniqueName。

ASPX

 < Telerik的:GridButtonColumn数据字段=Field1Value的HeaderText =自定义字段1UniqueName =Field1Value/>

ASPX.CS

 保护无效rdReport_ItemDataBound(对象发件人,GridItemEventArgs E)
{
    //编辑模式
    如果((e.Item是GridEditFormItem)及及(e.Item.IsInEditMode))
    {
        GridEditFormItem fndColumn =(GridEditFormItem)e.Item;
        。fnColumn [Field1Value] = Parent.Visible虚假的; //Field1Value是列uniquename
    }
}

让我知道如果你需要更多的信息。

<telerik:RadGrid runat="server" ID="rdReport" AutoGenerateColumns="false" AllowPaging="true" Skin="Metro"  OnItemCommand="ItemCommand" OnItemDataBound="rdReport_ItemDataBound" OnPreRender="rdReport_PreRender" DataSourceID="FountainSource" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true">
    <MasterTableView DataKeyNames="ID" CommandItemDisplay="None">
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" />                                   
            <telerik:GridBoundColumn DataField="LocName" HeaderText="Location" ReadOnly="true" /> 
            <     
            <telerik:GridBoundColumn DataField="Field1Value" HeaderText="Custom Field1" />
            <telerik:GridBoundColumn DataField="Field2Value" HeaderText="Custom Field2" />
            <telerik:GridBoundColumn DataField="Field3Value" HeaderText="Custom Field3" />

            <telerik:GridButtonColumn ConfirmText="Delete?" ConfirmDialogType="RadWindow"
                ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
        </Columns>
        <EditFormSettings>
            <EditColumn ButtonType="ImageButton" />
        </EditFormSettings>
    </MasterTableView>
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>

On Edit, I like to make a field invisible. I am using the following code which works but want to check to see if it is best practice:

protected void rdReport_ItemDataBound(object sender, GridItemEventArgs e)
{
    // Edit Mode
    if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
    {
        GridEditFormItem fndColumn = (GridEditFormItem)e.Item;
        fnColumn["Field1Value"].Parent.Visible = false;
    }
}

解决方案

The solution which was provided by you is perfect but it would be nice if you will also add UniqueName property in each column. If we will not assign the UniqueName than it is consider DataField value as UniqueName.

ASPX

<telerik:GridButtonColumn DataField="Field1Value" HeaderText="Custom Field1" UniqueName="Field1Value" />

ASPX.CS

protected void rdReport_ItemDataBound(object sender, GridItemEventArgs e)
{
    // Edit Mode
    if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode))
    {
        GridEditFormItem fndColumn = (GridEditFormItem)e.Item;
        fnColumn["Field1Value"].Parent.Visible = false; // "Field1Value" is column uniquename
    }
}

Let me know if you required more information.

这篇关于radgrid控件就编辑栏不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆