hi,
RadGrid will automatically show formtemplate content (such as label below: TEMPLATE APPEAR HERE) if I click on standard commandname 'InitInsert' or 'EditSelected' link:
Now, I introduce a custom commandName 'CopyCommand' to do the same to open formtemplate content.
It looks very simple but I just can't get it to work. Anyone knows a way to do this?
Thanks
Elvin
RadGrid will automatically show formtemplate content (such as label below: TEMPLATE APPEAR HERE) if I click on standard commandname 'InitInsert' or 'EditSelected' link:
... |
<FormTemplate> |
<asp:Label ID="Label1" runat="server" Text="TEMPLATE APPEAR HERE"></asp:Label> |
</FormTemplate> |
... |
<CommandItemTemplate> |
<div align="left"> |
<asp:LinkButton ID="initInsertLinkButton" runat="server" CommandName="InitInsert">Add new |
</asp:LinkButton> |
<asp:LinkButton ID="editSelectedLinkButton" runat="server" CommandName="EditSelected">Edit Selected |
</asp:LinkButton> |
<asp:LinkButton ID="copyLinkButton" runat="server" CommandName="CopyCommand"></asp:LinkButton> |
</div> |
</CommandItemTemplate> |
Now, I introduce a custom commandName 'CopyCommand' to do the same to open formtemplate content.
It looks very simple but I just can't get it to work. Anyone knows a way to do this?
Thanks
Elvin
6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2010, 11:43 AM
Hi Elvin,
Attach the ItemCommand and execute the following code snippet in order to simulate the EditSelected button behaviour.
C#:
-Shinu.
Attach the ItemCommand and execute the following code snippet in order to simulate the EditSelected button behaviour.
C#:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
if (e.CommandName == "CopyCommand") |
{ |
RadGrid1.SelectedItems[0].Edit = true; |
RadGrid1.MasterTableView.Rebind(); |
} |
} |
-Shinu.
0
Elvin Hau
Top achievements
Rank 1
answered on 14 Jun 2010, 06:58 AM
Thanks for hinting, Shinu.
From your code, as I don't want to force bind by a selected item (without which will throw a null exception), I modify to below:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "CopyCommand") |
{ |
e.Canceled = true; |
e.Item.OwnerTableView.InsertItem(); |
GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem(); |
HtmlTable formTable = insertedItem.FindControl("formTable") as HtmlTable; |
HtmlTable copyTable = insertedItem.FindControl("copyTable") as HtmlTable; |
formTable.visible = false; |
copyTable.visible = true; |
} |
} |
Again, the form template content doesn't open..?
0
Hello Elvin,
Attached to this message, is a small application, which handles a similar setup, and the insert form is properly shown. I hope it gets you started properly.
Regards,
Yavor
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.
Attached to this message, is a small application, which handles a similar setup, and the insert form is properly shown. I hope it gets you started properly.
Regards,
Yavor
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
Elvin Hau
Top achievements
Rank 1
answered on 18 Jun 2010, 06:50 PM
Your sample application completely solved my problem.
Thank you very much, Yavor.
Thank you very much, Yavor.
0
Joyce
Top achievements
Rank 1
answered on 13 Aug 2010, 12:57 AM
I almost want exactly the same behavior...
First I have a GridClientSelectColumn in my grid. I want to be able to select one or more records using the
It seems like this should be easier. I also tried to set AllowMultiRowEdit="True" in the grid but it fires a popup for every selected row.
Thanks for any help.
DC
First I have a GridClientSelectColumn in my grid. I want to be able to select one or more records using the
GridClientSelectColumn and fire the EditSelected command to open formtemplate that I have set it's EditMode='PopUp'. When my formtemplate displays only the last row is still selected in the grid. I want to have to user enter more data in the formtemplate and save that info for all the selected rows...
This is what I've tried to keep rows selected. nothing has worked so far
protected
void
Radgrid1_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.EditSelectedCommandName)
{
foreach
(GridItem gi
in
Radgrid1.SelectedItems)
{
Radgrid1.SelectedItems[0].Edit =
true
;
}
Radgrid1.MasterTableView.Rebind();
}
}
It seems like this should be easier. I also tried to set AllowMultiRowEdit="True" in the grid but it fires a popup for every selected row.
Thanks for any help.
DC
0
Princy
Top achievements
Rank 2
answered on 13 Aug 2010, 08:55 AM
Hello,
I guess your requirement is, you want to edit all the selected rows using a single pop up editform. For that the first step would be checking for 'SelectCommandName' in ItemCommand event and saving the DataKeyValue of all selected rows in an array. And then when updating loop through each of this items (using the datakeyvalue array) and prepare the update query for to update the db. Now rebind the grid to show the updated values.
Hope this information helps,
Princy.
I guess your requirement is, you want to edit all the selected rows using a single pop up editform. For that the first step would be checking for 'SelectCommandName' in ItemCommand event and saving the DataKeyValue of all selected rows in an array. And then when updating loop through each of this items (using the datakeyvalue array) and prepare the update query for to update the db. Now rebind the grid to show the updated values.
Hope this information helps,
Princy.