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

[Solved] RadGrid delete column

2 Answers 713 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 16 Dec 2009, 06:40 PM
ID="NotarySearchResultsGrid" runat="server" AutoGenerateColumns="false" OnNeedDataSource="NotarySearchResultsGrid_NeedDataSource" 
            OnItemCommand="NotarySearchResultsGrid_ItemCommand" AutoGenerateDeleteColumn="false" AutoGenerateEditColumn="false"    
            AllowDelete="false" AllowEdit="false" AllowInsert="false" AllowSorting="true"   
             ShowViewDetailsCommandColumn="false"   
            AllowPaging="true" PageSize="100" PagerStyle-Position="Bottom" PagerStyle-Mode="NextPrevAndNumeric" 
            > 
            <MasterTableView DataKeyNames="CommissionNumber" CommandItemDisplay="None"  > 
                <Columns> 
                    <telerik:GridButtonColumn HeaderText="Commission #" UniqueName="CommissionNumberColumn" ButtonType="LinkButton" DataTextField="CommissionNumber"      
                        CommandName="CommissionSelected" SortExpression="CommissionNumber" ></telerik:GridButtonColumn> 
                    <telerik:GridBoundColumn HeaderText="Name" UniqueName="NotaryNameColumn" DataField="Name" SortExpression="Name"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Address" UniqueName="AddressColumn" DataField="Address" SortExpression="Address"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="City" UniqueName="CityColumn" DataField="City" SortExpression="City"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Zip" UniqueName="ZipColumn" DataField="Zip" SortExpression="Zip"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="County" UniqueName="CountyColumn" DataField="County" SortExpression="County"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Status" UniqueName="StatusColumn" DataField="Status" SortExpression="Status"></telerik:GridBoundColumn> 
                </Columns> 
                <NoRecordsTemplate> 
                    <div> 
                        No records to display.  
                    </div> 
                </NoRecordsTemplate> 
            </MasterTableView> 
I am using a subclassed RadGrid control. The instance of which is defined as seen above.
However, the DeleteCommandColumn still appears with what looks to be a hyphen for the title. How can I remove this column?

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 18 Dec 2009, 10:59 AM
Hello Dennis,

I can't recreate your scenario with the provided code snippet, but generally, you can hide columns by setting Visible="false" -

+ declaratively;
+ programmatically in ColumnCreated;
+ programmatically in RadGrid_PreRender by using the MasterTableView's RenderColumns collection;

http://www.telerik.com/help/aspnet-ajax/grdusingcolumns.html
(see "Customizing columns programmatically")


Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dennis
Top achievements
Rank 1
answered on 18 Dec 2009, 01:32 PM
Thanks for the response Dimo. I appreciate it.

I ended up using the pre render event

protected void NotarySearchResultsGrid_PreRender(object sender, EventArgs e)  
        {  
            //forces delete command column to be hidden because it was still displaying even though properties were set to hide it  
            NotarySearchResultsGrid.MasterTableView.GetColumnSafe("DeleteCommandColumn").Visible = false;  
        }  

Works well.
Tags
Grid
Asked by
Dennis
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Dennis
Top achievements
Rank 1
Share this question
or