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

Hide 'Add New Record'

7 Answers 811 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott MacDonald
Top achievements
Rank 1
Scott MacDonald asked on 08 Jul 2010, 07:59 PM
this should be an easy one, but I haven't been able to find it in the documentation. I have a simple grid that is read-only where the user can click on a hyperlink column to view the record details. Since the user cannot add new records I want to not show the default 'Add new record' text and button that displays at the top of the grid.

thanks

7 Answers, 1 is accepted

Sort by
0
Carlos Contreras
Top achievements
Rank 1
answered on 08 Jul 2010, 09:31 PM
Hi Scott!

In your RadGrid properties, search for MasterTableView property, expand it, and then look for the CommandItemDisplay property and set it to None.

Good Luck!

By the way, does anybody know how to hide ONLY the Refresh command/option?
0
Shinu
Top achievements
Rank 2
answered on 09 Jul 2010, 05:15 AM
Hello,

You can simply set the  CommandItemSettings -> ShowAddNewRecordButton property to hide the "Add New Record" button.

<MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
    <CommandItemSettings ShowAddNewRecordButton="false" />


-Shinu.
0
Carlos Contreras
Top achievements
Rank 1
answered on 09 Jul 2010, 02:01 PM
Hi Sinu!

Is the ShowAddNewRecordButton property include in the last suite of Telerik RadControls?

Because we're useing the "RadControls for ASP.NET AJAX Q2 2009 SP1" and I don't have that property, or at least I can't found it, nor in the Properties Window, nor in the aspx code.

If that's true, then I guess there should be a ShowRefreshButton property too, isn't it? :)


Thanks!
0
Shinu
Top achievements
Rank 2
answered on 12 Jul 2010, 06:48 AM
Hello Carlos,


The property "ShowAddNewRecordButton" is added in Q1 2010 version (2010.1.216). Since you are using the old version, you could use the following code snippet in order to hide the "Add New Record" button.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
    {
        e.Item.FindControl("InitInsertButton").Parent.Visible = false;
    }
}


-Shinu.
0
Carlos Contreras
Top achievements
Rank 1
answered on 12 Jul 2010, 04:43 PM
Hi Shinu!

I used the code you provided, and it works perfectly!

But actually, I'm more interested in hide the Refresh button, and based on your example, I made a little change and it worked too!

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
    {
        e.Item.FindControl("RefreshButton").Parent.Visible = false;
    }
}

However, I'm still having a doubt about if there is a "ShowRefreshButton" property in Q1 2010 version (2010.1.216)?

I would greatly appreciate if you could resolve that doubt!


Thanks!
0
Shinu
Top achievements
Rank 2
answered on 13 Jul 2010, 06:44 AM
Hi Carlos,

The "ShowAddNewRecordButton" and "ShowRefreshButton" properties are added in CommandItemSettings class for Q1 2010 BETA (version 2010.1.216) and Q1 2010 (version 2010.1.309) onwards.

You can find out these in the release history here:
Q1 2010 BETA (version 2010.1.216)
Q1 2010 (version 2010.1.309)


-Shinu.
0
Carlos Contreras
Top achievements
Rank 1
answered on 19 Jul 2010, 07:51 PM
 That sounds great!

Thank you very much Shinu!
Tags
Grid
Asked by
Scott MacDonald
Top achievements
Rank 1
Answers by
Carlos Contreras
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or