This is a migrated thread and some comments may be shown as answers.

hide item on popup editform

7 Answers 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mydatafactory
Top achievements
Rank 1
Mydatafactory asked on 07 Jul 2009, 02:46 PM
Hello,

In my grid I have several columns with items. To edit the items I use the popup editform. Some of the items in the grid I want to hide on the popup editform. Although I searched the forum and tried several solutions the problem is still there.

Here's my .aspx code:
<telerik:RadGrid ID="gvTasksDataSteward" runat="server" AutoGenerateColumns="False" 
            DataSourceID="dsTasks" GridLines="None" Skin="Office2007" > 
            <ClientSettings EnablePostBackOnRowClick="true">  
            <Selecting AllowRowSelect="true" /> 
        </ClientSettings> 
            <MasterTableView DataSourceID="dsTasks" Name="DatastewardTasks" DataKeyNames="TaskId" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" EditMode="PopUp">  
                <RowIndicatorColumn Visible="False">  
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Visible="False" Resizable="False">  
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <Columns> 
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandProject" > 
                        <HeaderStyle Width="20px" /> 
                    </telerik:GridEditCommandColumn> 
                <telerik:GridBoundColumn DataField="TaskId" HeaderText="TaskId" UniqueName="TaskId" Visible="false"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company" SortExpression="Company" UniqueName="Company"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="ProjectName" HeaderText="Project" SortExpression="ProjectName" UniqueName="ProjectName"></telerik:GridBoundColumn> 
         <telerik:GridBoundColumn DataField="TaskDescription" HeaderText="TaskDescription" 
                        SortExpression="TaskDescription" UniqueName="TaskDescription">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Remarks" HeaderText="Remarks" SortExpression="Remarks" 
                        UniqueName="Remarks">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" HeaderText="StartDate" 
                        SortExpression="StartDate" UniqueName="StartDate" DataFormatString="{0:d}">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="SoortBewerking" HeaderText="SoortBewerking" SortExpression="SoortBewerking" 
                        UniqueName="SoortBewerking">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="RealHours" DataType="System.Decimal" HeaderText="RealHours" 
                        SortExpression="RealHours" UniqueName="RealHours" Visible="false">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="StatusId" UniqueName="StatusId" Visible="false"></telerik:GridBoundColumn> 
                      
                      
                    <telerik:GridButtonColumn ButtonType="PushButton" UniqueName="Accept" Text="Accept" ImageUrl="~/Images/OK.png" ShowInEditForm="false" CommandName="Accepted"></telerik:GridButtonColumn> 
                    <telerik:GridButtonColumn ButtonType="PushButton" UniqueName="NotAccept" Text="Not Accept" ImageUrl="~/Images/OK.png" ShowInEditForm="false" CommandName="NotAccepted"></telerik:GridButtonColumn> 
                    <telerik:GridButtonColumn ButtonType="PushButton" UniqueName="Executed" Text="Executed" ImageUrl="~/images/11new.gif" ShowInEditForm="false" CommandName="Executed" ConfirmText="Executed?"></telerik:GridButtonColumn> 
 
                </Columns> 
                <EditFormSettings CaptionFormatString="Edit: {0}" CaptionDataField="ProjectName">  
                    <PopUpSettings ScrollBars="Auto" ></PopUpSettings>  
                    <EditColumn ButtonType="ImageButton" CancelText="Cancel Edit" UpdateText="Update Task" 
                        InsertText="Insert User" UniqueName="EditCommandColumn">  
                    </EditColumn> 
                    <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> 
                </EditFormSettings> 
            </MasterTableView> 
        </telerik:RadGrid> 

And here's one of the solutions I've tried:

 

Protected Sub gvTasksDataSteward_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvTasksDataSteward.PreRender

 

       
        For Each item As GridDataItem In gvTasksDataSteward.EditItems  
            Dim itemToEdit As GridEditableItem = If((item.OwnerTableView.EditMode = GridEditMode.PopUp), DirectCast(item, GridEditableItem), DirectCast(item.EditFormItem, GridEditableItem))  
 
            itemToEdit("StatusId").Visible = False 
        Next
End sub

7 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Jul 2009, 03:45 PM
Hello,

Editable column have a ReadOnly property that determines whether the column editor is visible in the edit form or not. If you want the column editor does not appear in the edit form you should set a ReadOnly property to True.
Find more information in the following article:
Column types

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mydatafactory
Top achievements
Rank 1
answered on 13 Jul 2009, 08:39 AM
Thanks for your reply. Setting the ReadOnly property to True was the solution.
0
Toby
Top achievements
Rank 1
answered on 08 May 2012, 11:52 AM
Setting a column to readonly stops it being available on updates using the following code :

if Id is set to readonly it will not be available here :

protected void ScriptConfigGrid_UpdateCommand(object source, GridCommandEventArgs e)
{
    GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
    Hashtable ht = new Hashtable();
    gridEditFormItem.ExtractValues(ht);
    string Id = ConvertNullToEmpty(ht["Id"]);
0
Shinu
Top achievements
Rank 2
answered on 08 May 2012, 12:59 PM
Hi Toby,

One suggestion is to set the id as DatakeyName and can access it in the UpdateCommand.

C#:
protected void ScriptConfigGrid_UpdateCommand(object source, GridCommandEventArgs e)
{
    GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
    Hashtable ht = new Hashtable();
    string Id= (e.Item).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UniqueName"].ToString();   // Get the DataKeyValue
    gridEditFormItem.ExtractValues(ht);
}

Thanks,
Shinu.
0
Toby
Top achievements
Rank 1
answered on 08 May 2012, 01:27 PM
thanks for that, for some reason (e.Item).OwnerTableView.DataKeyValues is an empty array, I have added the datakeynames to the grid i.e.

<telerik:RadGrid ID="ScriptConfigGrid" runat="server" Visible="true" AutoGenerateColumns="false" 
                               AllowMultiRowSelection="true" PageSize="12" Width="420" AllowPaging="true" DataKeyNames="Id"
                               OnNeedDataSource="ScriptConfigGrid_NeedDataSource"
                               OnUpdateCommand="ScriptConfigGrid_UpdateCommand" OnItemDataBound="ScriptConfigGrid_ItemDataBound"
                               OnInsertCommand="ScriptConfigGrid_InsertCommand" OnDeleteCommand="ScriptConfigGrid_DeleteCommand" >
                               <MasterTableView CommandItemDisplay="Top" EditMode="PopUp">

anything else I need to do?

the datasource is a generic list, which is set in the code on the page_load

thanks
0
Shinu
Top achievements
Rank 2
answered on 08 May 2012, 01:49 PM
Hi Toby,

Please provide the DataKeyNames to the MasterTableView as shown below.

ASPX:
<telerik:RadGrid ID="ScriptConfigGrid" runat="server" Visible="true" AutoGenerateColumns="false"
                               AllowMultiRowSelection="true" PageSize="12" Width="420" AllowPaging="true"
                               OnNeedDataSource="ScriptConfigGrid_NeedDataSource"
                               OnUpdateCommand="ScriptConfigGrid_UpdateCommand" OnItemDataBound="ScriptConfigGrid_ItemDataBound"
                               OnInsertCommand="ScriptConfigGrid_InsertCommand" OnDeleteCommand="ScriptConfigGrid_DeleteCommand" >
                            <MasterTableView CommandItemDisplay="Top" EditMode="PopUp"  DataKeyNames="Id">

Thanks,
Shinu.
0
Toby
Top achievements
Rank 1
answered on 08 May 2012, 01:55 PM
ah my fault, working perfectly now, thanks for the quick responce!
Tags
Grid
Asked by
Mydatafactory
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Mydatafactory
Top achievements
Rank 1
Toby
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or