I am trying to create fuctionality which will allow the user to see the preview/ReadOnly mode by clicking on a row in the Grid. The user will be able to expand/collapse the row to show/hide the preview mode. In the javascript function
I am using the fireCommand() function passing in the "Preview" commandName and the selected Index:
function RowSelected(sender, eventArgs)
{
var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
masterTable.fireCommand("Preview",eventArgs.get_itemIndexHierarchical());
}
Although this will raise the correct event, the itemIndex is getting lost. The result is that only the first row expands to display the Preview mode no matter which row is clicked. Instead, I need the selected row to display it's preview mode.
I am using webcontrols for edit and insert (EditFormType="WebUserControl"). In the server side code I am checking for the "preview" command.
protected void RadGrid1_ItemCommand1(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
e.Canceled = true;
RadGrid1.EditIndexes.Clear();
e.Item.OwnerTableView.EditFormSettings.UserControlName = "InsertContactForm.ascx";
e.Item.OwnerTableView.InsertItem();
}
else if (e.CommandName == RadGrid.EditCommandName)
{
e.Item.OwnerTableView.IsItemInserted = false;
e.Item.OwnerTableView.EditFormSettings.UserControlName = "EditContactForm.ascx";
}
else if (e.CommandName == "Preview")
{
e.Item.Edit = true;
e.Item.OwnerTableView.Rebind();
GridDataItem editItem = e.Item.OwnerTableView.Items[e.Item.ItemIndex];
e.Item.OwnerTableView.EditFormSettings.UserControlName = "EditContactForm.ascx";
string sUcID = GridEditFormItem.EditFormUserControlID;
UserControl MyUserControl = (UserControl)editItem.EditFormItem.FindControl(sUcID);
ASP.contacts_editcontactform_ascx eForm = (ASP.contacts_editcontactform_ascx)MyUserControl;
eForm.SetPreviewMode();
}
}
Any ideas of how I can get the correct row to expand?
Also, Since I will need to cancel out of the preview mode once the user clicks the same row again, can you tell me how to check (on the client side) if the selected row is in "Preview" mode?
Thanks!