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
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
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
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.
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
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.
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
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,
Tsvetoslavthe 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.
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
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.
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
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.
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.
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.