Drop Column Runtime

9 posts, 0 answers
  1. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 21 Mar 2010 Link to this post

    Hello

    Is is possible for the user to drop a column from the grid at runtime? if so, how is this implimented?

    We are saving the layout of the grids now as a profile xml and want to allow the user to also drop columns and save that as a new profile.

    Nick
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 22 Mar 2010 Link to this post

    Hello Nick Wood,

    Could you please take a look at our HeaderContextMenu example which demonstrates one possible approach. 


    Greetings,
    Milan
    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. DevCraft banner
  4. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 22 Mar 2010 Link to this post

    Hi Milan

    Thankyou for that link

    I have tried adding this code but when I right click on the grid it still only show "Silverlight" and no menu
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 22 Mar 2010 Link to this post

    Hi Nick Wood,

    With Silverlight 3 the right-click functionality is only available when the Silverlight plug-in runs in Windowless mode. To get the sample working just create a web application that hosts your SL application and edit the  startup .aspx file. The last couple of line of this file should look something like:

    <body>
        <form id="form1" runat="server" style="height:100%">
        <div id="silverlightControlHost">
            <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
              <param name="source" value="ClientBin/SilverlightApplication1.xap"/>
              <param name="onError" value="onSilverlightError" />
              <param name="background" value="white" />
              <param name="minRuntimeVersion" value="3.0.40624.0" />
              <param name="autoUpgrade" value="true" />
              <!-- enables Windowless mode -->
              <param name="Windowless" value="true" />
              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
                  <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
              </a>
            </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
        </form>
    </body>

    To enable Windowless mode just add a new "param" element and you should be good to go.

    <param name="Windowless" value="true" />

    Best wishes,
    Milan
    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.
  6. Hakki
    Hakki avatar
    47 posts
    Member since:
    Sep 2012

    Posted 17 Oct 2013 Link to this post

    Sorry for the bump but this is by far the best example I could Google find. I have got the menu working when I applied it in XAML as per your example.

    So now, how do I apply it to a RadGrid that is created at runtime using C#?

    The following is saying "Cannot Resolve symbol IsEnabled":

    _grid = new RadGridView
    {
        Name = "GeneratedGrid" + _dataNo,
        AutoGenerateColumns = true,
        ShowGroupPanel = false,
        GridViewHeaderMenu.IsEnabled = true,
        VerticalAlignment = VerticalAlignment.Top,
        RowIndicatorVisibility = Visibility.Collapsed,
        ShowColumnHeaders = true,
        IsReadOnly = true,
        Margin = new Thickness(10, 74, 0, 0)
    };

    Help appreciated, thanks.
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 Oct 2013 Link to this post

    Hi,

    RadGridView does not have a property GridViewHeaderMenu. You can refer to its API.
    Please check our online demo on how to define a header ContextMenu. 

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. Hakki
    Hakki avatar
    47 posts
    Member since:
    Sep 2012

    Posted 22 Oct 2013 Link to this post

    Hello,

    It works fine per demo. But demo shows how to apply the HeaderMenu only via XAML. I am creating grids at run time via C# (it is needed as user can create as many as they like) per my code in my last post, and need to know how I apply the HeaderMenu to grids that are created like that?

    Thanks.
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 Oct 2013 Link to this post

    Hello,

    You can apply it in code behind similar to:

    public MainWindow()
    {
       InitializeComponent();
       GridViewHeaderMenu.SetIsEnabled(this.playersGrid, true);
    }


    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  10. Hakki
    Hakki avatar
    47 posts
    Member since:
    Sep 2012

    Posted 22 Oct 2013 Link to this post

    That did it, thanks.
Back to Top
DevCraft banner