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

Drop Column Runtime

8 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nick Wood
Top achievements
Rank 1
Nick Wood asked on 21 Mar 2010, 11:45 PM
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

8 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 22 Mar 2010, 11:19 AM
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.
0
Nick Wood
Top achievements
Rank 1
answered on 22 Mar 2010, 12:29 PM
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
0
Milan
Telerik team
answered on 22 Mar 2010, 01:35 PM
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.
0
Hakki
Top achievements
Rank 1
answered on 17 Oct 2013, 09:56 AM
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.
0
Dimitrina
Telerik team
answered on 22 Oct 2013, 08:41 AM
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 >>
0
Hakki
Top achievements
Rank 1
answered on 22 Oct 2013, 10:45 AM
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.
0
Dimitrina
Telerik team
answered on 22 Oct 2013, 11:37 AM
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 >>
0
Hakki
Top achievements
Rank 1
answered on 22 Oct 2013, 01:25 PM
That did it, thanks.
Tags
GridView
Asked by
Nick Wood
Top achievements
Rank 1
Answers by
Milan
Telerik team
Nick Wood
Top achievements
Rank 1
Hakki
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or