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

Contextmenu in empty grid

3 Answers 136 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
usha
Top achievements
Rank 1
usha asked on 03 Sep 2012, 06:33 AM
Hi,

    I have a tree view with folder structure. when i double click on any folder it displays all files and folder in a grid. that grid consisiting of context menu with some options. now my question is how to display context menu on grid when i double click on folder if that folder contains no records and folders(means displaying context menu on empty Rad Grid).

Thanks in adv
usha.

3 Answers, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 06 Sep 2012, 07:15 AM
Hello Usha,

You could achieve your scenario by setting the RadGrid DataSource property to a empty list of objects which will cause the grid to show its NoRecordsTemplate so the context menu will be accessible. Additionally, you could use the RadContextMenu showAt function and specify the x and y coordinates of the grid.
this.RadGrid1.DataSource = new List<object>();

Regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
usha
Top achievements
Rank 1
answered on 07 Sep 2012, 12:27 PM
Hi Antonio Stoilkov ,

can u  please give me a sample how to populate context menu on empty grid using show at function .

Thanks in adv,
usha


0
Antonio Stoilkov
Telerik team
answered on 12 Sep 2012, 06:55 AM
Hello Usha,

I have assembled a sample project demonstrating how the desired functionality could be implemented. The idea is to include the RadGrid in the RadContextMenu Targets collection as it is shown below. Note that binding to a source with no records is required to show the grid.
<telerik:RadContextMenu ID="RadContextMenu1" runat="server">
    <Targets>
        <telerik:ContextMenuControlTarget ControlID="RadGrid2" />
    </Targets>
    <Items>
        <telerik:RadMenuItem Text="Item1" Value="Value1">
        </telerik:RadMenuItem>
        <telerik:RadMenuItem Text="Item2" Value="Value2">
        </telerik:RadMenuItem>
    </Items>
</telerik:RadContextMenu>
<telerik:RadGrid ID="RadGrid2" runat="server" OnNeedDataSource="RadGrid2_NeedDataSource">
    <MasterTableView>
        <NoRecordsTemplate>
            No recods available. Right-click for context menu.
        </NoRecordsTemplate>
    </MasterTableView>
</telerik:RadGrid>

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
usha
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
usha
Top achievements
Rank 1
Share this question
or