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

Hide Add new record command item

11 Answers 795 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 18 Mar 2010, 04:33 PM
I found the tutorial that talked about hiding the default command items, but I don't think it showed how to do it.  When I use the CommandItemSettings tag I only find the Show command for the four export types and not the Add new or Refresh item.  How can I hide the "Add new record" command item?

Sorry if this is an elementary issue.  I can't figure out how to do it....

11 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Mar 2010, 04:52 PM
Hello Matt,

Please try the following approach:
<MasterTableView CommandItemDisplay="Top" ...>
    <CommandItemSettings ShowAddNewRecordButton="false" />

In the older versions of RadControls, you could hide the button on ItemCreated.
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
        e.Item.FindControl("InitInsertButton").Parent.Visible = false;
}

Let me know if you need further assistance.

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Matt
Top achievements
Rank 1
answered on 18 Mar 2010, 07:34 PM
In what version is that available?  When I try that this is what I get:

Type 'Telerik.Web.UI.GridCommandItemSettings' does not have a public property named 'ShowAddNewRecordButton'.
0
Princy
Top achievements
Rank 2
answered on 19 Mar 2010, 08:03 AM
Hi,

The ShowAddNewRecordButton and ShowRefreshButton properties in CommandItemSettings class are available in the
Q1 2010 (version 2010.1.309) 

Princy
0
Daniel
Telerik team
answered on 23 Mar 2010, 08:40 PM
Hello Matt,

If you have an older version of RadControls for ASP.NET AJAX you can use the second approach -it hides the button programatically.

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
towpse
Top achievements
Rank 2
answered on 06 Apr 2010, 03:31 PM
How do you show the export command items in older versions?
2009.3.1314.35 doesn't seem to expose the showExportToExcel Client Settings property.
0
Daniel
Telerik team
answered on 06 Apr 2010, 06:17 PM
Hello Matt,

The built-in export buttons can be enabled in the CommandItemSetting section:
<MasterTableView  ...>
    <CommandItemSettings
        ShowExportToCsvButton="true" 
        ShowExportToExcelButton="true"
        ShowExportToPdfButton="true"
        ShowExportToWordButton="true" />

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
towpse
Top achievements
Rank 2
answered on 06 Apr 2010, 06:29 PM
Nice. Thanks.
Now, is there an equivalent to these item commands for the grid filter? Is there an out of the box command item for the filtering feature with an appropriate icon?

cheers
0
sln007
Top achievements
Rank 1
answered on 08 Apr 2010, 07:38 PM
Telerik Team,

Is the only way to "disable" the InitInsertButton, to not show it.  There does not seem to be an 'Enable' property.

We'd like to leave it there, just disable its use.
0
Daniel
Telerik team
answered on 08 Apr 2010, 07:55 PM
Hello,

@sln007: You can easily disable the desired buttons in code-behind.
protected void rg1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
        (e.Item.FindControl("InitInsertButton").Parent as TableCell).Enabled = false;
}

@Matt: No, there are no built-in filtering controls in the commanditem. I recommend you just create a custom command template and define its layout as suitable for you. You can also try our new control - RadFilter:
RadGrid filtering with RadFilter

Kind regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rick
Top achievements
Rank 1
answered on 02 Mar 2014, 11:05 AM
Has something changed with this functionality?  I have a RadGrid and I want the AddNewRecord button to be enabled/disabled based on the user's permissions.

If I set:

ShowAddNewRecordButton="false"

in the declaration, the button is now shown (correct).

But if I put this in the OnPreRender event handler:

ListGrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;

the first time that the grid is rendered (even if this line is executed - which it is) then the button will not be shown, but if I hit the Refresh button or do anything else that creates a callback then the button is rendered properly.

Any ideas?
0
Princy
Top achievements
Rank 2
answered on 03 Mar 2014, 03:50 AM
Hi Rick,

You must Rebind() the grid in the PreRender event after setting any properties.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
  RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
  RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;
  RadGrid1.Rebind();
}

Thanks,
Princy
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Matt
Top achievements
Rank 1
Princy
Top achievements
Rank 2
towpse
Top achievements
Rank 2
sln007
Top achievements
Rank 1
Rick
Top achievements
Rank 1
Share this question
or