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

Prevent expand if parent row is not highlighted.

3 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 16 Dec 2010, 01:01 AM

Folks, Using Telerik ASP.NET Ajax 2010 built 3 with VS 2010.

I have a hierachal radgrid. I would like to prevent users with an alert message to expand the Row without selecting the Row 1st.

For example, if Parent row 1 is selected, then if I click to expand Parent row 2 without selecting Parent row 2
-- Although Parent row 1 is still selected, but Parent row 2 expands.

I understand from this for single/expand:
http://www.telerik.com/help/aspnet-ajax/grdsingleexpandinhierarchicalgrid.html

Basically

- Attached file is my desire result (Child Expanded After Parent Row Highlighted.JPG)

- Attached file is NOT my desire result (Child Expanded without Parent Row Highlighted.JPG)

Thanks.
GC_0620

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Dec 2010, 06:42 AM
Hello,

In order to achieve this, try the following client side code.

ASPX:
<ClientSettings Selecting-AllowRowSelect="true">
    <ClientEvents OnCommand="OnCommand" />
</ClientSettings>

Java Script:
function OnCommand(sender, args)
     {
        if (args.get_commandName() == "ExpandCollapse") {
            if (!args.get_tableView().get_dataItems()[args.get_commandArgument()].get_selected())
           {
             alert("select row first");
                args.set_cancel(true);
           }
       }
    }

If you have set HierarchyLoadMode="Client" , you can try the following code snippet:
ASPX:
<ClientSettings Selecting-AllowRowSelect="true">
    <ClientEvents OnHierarchyExpanding="OnHierarchyExpanding"/>
</ClientSettings>

Java Script:
function OnHierarchyExpanding(sender, args) {
   if (!args.get_gridDataItem().get_selected())
      {
            alert("select row first");
            args.set_cancel(true);
       }
   }

Thanks,
Princy.
0
gc_0620
Top achievements
Rank 1
answered on 17 Dec 2010, 01:45 AM
Thanks Princy, your solution works. I follow your, Shinu's, Daniel's and other Telerik post's all the time. As a matter of fact all of your's posts are bookmarked in my favourites (attached). Many of the questions can be easilty found there. 

Thanks for helping me from the begining while I know nothing how Telerik controls works. I appreciate very much.

All the best and a Happy New Year to you, Shinu, Daniel & support team from Telerik and all Telerik users.

Sincerely

gc_0620



0
Princy
Top achievements
Rank 2
answered on 17 Dec 2010, 06:10 AM
Hi,


I am so glad to know that your issue is solved.  :)
I wish you to 'be a part of solution, not the problem', in the coming year! :) Merry Christmas and a happy new year to you.


Regards,
Princy.
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
gc_0620
Top achievements
Rank 1
Share this question
or