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

Row Click shows NestedTemplate, Edit button Shows Edit Template

15 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 20 Apr 2009, 04:47 PM
I'm attempting to get my RadGrid to show the NestedTemplate when the row is clicked, but show the edit template when the Edit button (created via a GridEditCommandColumn) is clicked.

In my ItemCommand handler, I have the following code:

if(e.Item is GridDataItem)  
{  
  if(e.CommandName == "RowClick")  
  {  
      if(e.Item.Selected)  
      {  
          e.Item.Selected = false;  
          e.Item.Expanded = false;  
      }  
      else 
      {  
          e.Item.Selected = true;  
          e.Item.Expanded = true;  
      }  
 
      e.Item.Edit = false;  
  }  
  else if(e.CommandName == "Edit")  
  {  
      e.Item.Selected = true;  
      e.Item.Expanded = false;  
      e.Item.Edit = true;  
      myGrid.Rebind();  
  }  

This code works fine for selecting the row via a RowClick, but the ItemCommand fires twice for the Edit button click, once with a CommandName of Edit, and then once with a CommandName of RowClick. This results in the row showing the NestedTemplate instead of the EditTemplate.

Futhermore, it appears that the state from the first ItemCommand event does not exist for the second ItemCommand event. In other words, the fact that I set the row to Selected and Expanded does not show up when the second ItemCommand event is handled, so I can't check this information and prevent the RowClick from messing things up.

What am I doing wrong?

15 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Apr 2009, 06:57 AM

Hi,

A suggestion would be to use a global variable which you could set in the edit command and check the same in the ROwClick.You can then cancel the Expand in the condition as  shown below:

public static int flag = 0
 
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        { 
            if (e.CommandName == "RowClick") 
            { 
 
                if (flag == 1) 
                { 
                    e.Item.Selected = true
                    e.Item.Expanded = false
                    e.Item.Edit = true
                    RadGrid1.Rebind(); 
                } 
            } 
            else if (e.CommandName == "Edit") 
            { 
                flag = 1
            }   
        } 

Thanks,
Princy
0
Chirag Dedhia
Top achievements
Rank 1
answered on 26 Jan 2010, 01:34 PM
Hi Robert,

Did you find a solution to this? As i am also facing the same problem.

Even after decalraing the global flag as mentioned by Princy it reintialises the variable & do not get the desired result.
Please let me know if you have a solution for this.

Thanks & Regards
Chirag Dedhia
0
Tsvetoslav
Telerik team
answered on 29 Jan 2010, 06:53 AM
Hello Chirag,

Try attaching a client handler to the grid's ClientSettigns.ClientEvents.OnRowClick event, get a reference to the dom event object, check if the source element (target element) is an edit button and cancel the event (args.set_cancel(true)).

Do let us know of the result.

Greetings,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chirag Dedhia
Top achievements
Rank 1
answered on 29 Jan 2010, 10:16 AM
Hi Tsvetoslav,

Thanks for the reply. I had raised this query on another post where i have explained my scenario in detail. Will you please go through the following post & provide me a solution.

http://www.telerik.com/community/forums/aspnet-ajax/grid/execute-same-method-for-expandcollapse-or-rowclick.aspx

Thanks & Regards
Chirag Dedhia
0
Tsvetoslav
Telerik team
answered on 03 Feb 2010, 05:26 PM
Hi Chirag,

I tested your scenario and it turns out that there might be some issue with the way client events are fired for the grid under this scenario. I have related the case to our developer team and we shall get back to you with further information as soon as possible.

Regards,
Tsvetoslav
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Chirag Dedhia
Top achievements
Rank 1
answered on 04 Feb 2010, 10:35 AM
Hi Tsvetoslav,

Thanks for looking. In the mean time i have got it working the way i want. Instead of firing the postback by setting the Clientsettings

"EnablePostBackOnRowClick

 

= true" i am now calling the RaisePostBack event using javascript.

To give you more details i am doing as follows:

JS:

<script type="text/javascript">  
    function RowClick(index) {  
        __doPostBack("<%= this.UniqueID %>", "RowClick");  
    }  
    </script> 

ASPX:

        <ClientSettings EnableRowHoverStyle="true">  
            <Resizing AllowColumnResize="true" /> 
            <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
            <ClientEvents OnRowClick="RowClick"></ClientEvents> 
            <Selecting AllowRowSelect="True" /> 
        </ClientSettings> 

CS:

void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)     
        {     
            switch (eventArgument)     
            {     
                case "RowClick":     
                    //Code goes here     
                    break;     
            }     
         }   

But now i have another issue. I have lost the ajaxification when i do this. So as soon as i click on the row it does a normal postback instead of ajaxifying the page. To give you more details

I am using a Master Content Form. The aspx page has a usercontrol with the grid on it. So all of the above code shown is in usercontrol. Now we have the RadAjaxLoadingPanel on the master page & the RadAjaxPanel on the aspx pages. This works well for everything as in it ajaxifies all the controls but doesnt work when i click on the grid row in the usercontrol.

Please let me know how can i overcome this.

Thanks & Regards
Chirag Dedhia

0
Tsvetoslav
Telerik team
answered on 17 Feb 2010, 12:40 PM
Hi Chirag,

I am glad to inform you that our development team has addressed the issue we have discussed in the current forum thread. The fix should soon be available in the next latest internal build of the controls that you can download from your customer's account. In addition, I have updated your Telerik points accordingly. 

Regards,

Tsvetoslav
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
Chirag Dedhia
Top achievements
Rank 1
answered on 17 Feb 2010, 02:34 PM
Hi Tsvetoslav,

Thanks for the update & points. Can you please clarify which issue are you going to correct in the next release? Is it the RadGrid expand / collapse firing row click or the Radajax working on Raisepostback.

Thanks once again. Also how would i be notified when this fix is released?

Regards
Chirag Dedhia
0
Tsvetoslav
Telerik team
answered on 18 Feb 2010, 11:34 AM
Hi Chirag,

That's exactly the issue I was referring to.  The build should be available in the beginning of next week. The current latest build is 2009_14_07, so as soon as the next one appears in the Latest Internal Builds section of  your customer account - that's the one that should contain the fix.

All the best,
Tsvetoslav
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
Chirag Dedhia
Top achievements
Rank 1
answered on 18 Feb 2010, 11:41 AM
Hi Tsvetoslav,

Sorry which issue exactly it is. I had raised two
1. Expand Collapse issue on Radgrid
2. No ajaxification on Raisepostback.

Please let me know which one do i expect in the next release so that i can update my code accordingly.

Thanks & Regards
Chirag Dedhia
0
Tsvetoslav
Telerik team
answered on 22 Feb 2010, 09:06 AM
Hi Chirag,

Excuse me for having missed to clarify this point - the fix is related to the Expand/Collapse issue.

Regards,
Tsvetoslav
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
Developer
Top achievements
Rank 1
answered on 18 Mar 2010, 05:48 PM
Hi Admin,

I am facing the similar problem but without nested views.

I have a single MasterTableView and in that I have a TemplateColumn with a RadCombo and a command button in it, I have given the CommandName for that button as "Assigned", I am handling the event in ItemCommand event of RadGrid, its working fine. But also I am using built-in "RowClick" command name to redirect the user, if they click anywhere else other than TemplateColumn.


Now, if I click on TemplateColumn, then it does the operation of "Assigned"  and then it repeats the ItemCommand procedure and this time "RowClick" operation is performed, which I don't want.

Any help please?

Regards.
0
Developer
Top achievements
Rank 1
answered on 18 Mar 2010, 07:32 PM
Hello again Admin,

Don't worry, for now I have put EnablePostBackOnRowClick="false" and put a client event "OnRowClick" on OnRowClick and redirected through that. RadGrid's ItemCommand is still fired when I click on CommandButton so both are solved.  

Somehow, page was losing the flag value, the method suggested by Princy was failing. Anyway its sorted, thanks.


Regards.
0
Chirag Dedhia
Top achievements
Rank 1
answered on 30 Mar 2010, 11:38 AM
Hi Tsvetoslav,

I think this issue is fixed with the Licensed version that i am using, but can you please let me know the exact date when this was released as i need to go back to that date in my Source Control & do the neccessary changes.

Thanks for all the support & help.

Regards
Chirag Dedhia.
0
Tsvetoslav
Telerik team
answered on 30 Mar 2010, 02:47 PM
Hi Chirag,

The fix was implemented on the 14th of February 2010. So all the builds after this date should contain it. The only official build in this row is the Q1 2010 one and all the latest internal builds after it.

Regards,
Tsvetoslav
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.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Chirag Dedhia
Top achievements
Rank 1
Tsvetoslav
Telerik team
Developer
Top achievements
Rank 1
Share this question
or