Hide Add new record command item

12 posts, 0 answers
  1. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 18 Mar 2010 Link to this post

    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....
  2. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 18 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matt
    Matt avatar
    66 posts
    Member since:
    Apr 2009

    Posted 18 Mar 2010 Link to this post

    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'.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Mar 2010 Link to this post

    Hi,

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

    Princy
  6. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 23 Mar 2010 Link to this post

    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.
  7. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 06 Apr 2010 Link to this post

    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.
  8. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 06 Apr 2010 Link to this post

    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.
  9. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 06 Apr 2010 Link to this post

    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
  10. sln007
    sln007 avatar
    6 posts
    Member since:
    Feb 2009

    Posted 08 Apr 2010 Link to this post

    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.
  11. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 08 Apr 2010 Link to this post

    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.
  12. Rick
    Rick avatar
    1 posts
    Member since:
    Sep 2011

    Posted 02 Mar 2014 in reply to Daniel Link to this post

    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?
  13. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Mar 2014 in reply to Rick Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017