We are using the OnRowDblClick to enable updating of row items as per your provided samples. However, not every row should be editable depending on the user. Is there a way to disable the double-click functionality for certain rows in the OnItemDataBound event or another grid event?
Thanks!
Thanks!
7 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 29 Sep 2008, 05:22 AM
Hi Christian,
One suggestion will be to add the onDblClick client event to the items in the ItemDataBound event depending on the condition.
CS:
JS:
Thanks
Shinu.
One suggestion will be to add the onDblClick client event to the items in the ItemDataBound event depending on the condition.
CS:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem item = (GridDataItem)e.Item; |
string strtxt = item["ProductName"].Text.ToString(); |
if (strtxt != "Chai") |
{ |
item.Attributes.Add(" onDblClick", "return RowDblClick();"); |
} |
} |
} |
JS:
<script type="text/javascript" language="javascript" > |
function RowDblClick() |
{ |
__doPostBack("<%= RadGrid2.UniqueID %>") |
} |
</script> |
Thanks
Shinu.
0
Christian
Top achievements
Rank 1
answered on 29 Sep 2008, 05:57 AM
Hi Shinu,
Thank you for the idea and the code. This should work perfectly. I could still use a little help though. The Javascript function that setst he edited row looks like this:
This is taken from the Telerik sample on how to do this. What would the code behind look like to set the "sender" and "eventArgs?" Thanks again for your help.
Regards,
Christian
Thank you for the idea and the code. This should work perfectly. I could still use a little help though. The Javascript function that setst he edited row looks like this:
function RowDblClick(sender, eventArgs) |
{ |
editedRow = eventArgs.get_itemIndexHierarchical(); |
$find("<%= grdActivities.MasterTableView.ClientID %>").editItem(editedRow); |
} |
This is taken from the Telerik sample on how to do this. What would the code behind look like to set the "sender" and "eventArgs?" Thanks again for your help.
Regards,
Christian
0
Princy
Top achievements
Rank 2
answered on 29 Sep 2008, 07:47 AM
Hi Christian,
Try with the following code snippet to achieve the desired scenario.
CS:
JS:
Hope this helps..
Princy
Try with the following code snippet to achieve the desired scenario.
CS:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem item = (GridDataItem)e.Item; |
int rowindx = item.ItemIndex; |
string strtxt = item["ProductName"].Text.ToString(); |
if (strtxt != "Chai") |
{ |
item.Attributes.Add(" onDblClick", "return RowDblClick('" + rowindx + "');"); |
} |
} |
} |
JS:
<script type="text/javascript" language="javascript" > |
function RowDblClick(rowindx) |
{ |
var Grid = $find("<%=RadGrid2.ClientID %>"); |
Grid.MasterTableView.editItem(rowindx); |
} |
</script> |
Hope this helps..
Princy
0
Christian
Top achievements
Rank 1
answered on 30 Sep 2008, 09:37 PM
This will work great. Thank you. However, can you please tell me what the RowClick function should look like now to update the row... Currently I have it copied from your samples as:
function RowClick(sender, eventArgs) |
{ |
if(editedRow && hasChanges) |
{ |
hasChanges = false; |
if(confirm("Update changes?")) |
{ |
$find("<%= grdActivities.MasterTableView.ClientID %>").updateItem(editedRow); |
} |
} |
} |
Thank you once again for your help.
Christian
0
Accepted
Hi Christian,
The editedRow is a variable which holds reference to the currently double-clicked index. Thus, you can get a reference to the row on the client as well.
Kind regards,
Yavor
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The editedRow is a variable which holds reference to the currently double-clicked index. Thus, you can get a reference to the row on the client as well.
Kind regards,
Yavor
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 01 Oct 2008, 09:53 PM
OK, so I'm setting the editedRow in the RowDblClick function now and it seems to work OK Please see the "RowClick" function above copied from your samples. When a row is in edit mode, how do I get it out of edit mode WITHOUT updating on the client? So for example, when the user is prompted with the confirmation box in the RowClick function, if they want to cancel and get out of edit mode, how is that done on the client?
And is there some sort of reference on your site to the different client functions such as updateItem(), etc. so that I can know what they are.
Thank you.
Christian
And is there some sort of reference on your site to the different client functions such as updateItem(), etc. so that I can know what they are.
Thank you.
Christian
0
Christian
Top achievements
Rank 1
answered on 01 Oct 2008, 10:05 PM
I found it (cancelUpdate) here: http://www.telerik.com/help/aspnet-ajax/grid_cancelupdate.html.
Thanks!
Thanks!