Hi I have a RadCombox column in each GridRow called "Actions". when I select action "Edit" I want to start editing the record, when I select action "Delete" I want to delete the record, when I select action "ActionC" I want to open a different RadWindow. Is this achievable? please help, thanks in advance
<telerik:GridTemplateColumn UniqueName="GridTemplateColumn1" ItemStyle-HorizontalAlign="Center" AllowFiltering="false">
<ItemTemplate>
<telerik:RadComboBox ID="RadComboBox1" runat="server">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Select Action..." Value="SelectAction" />
<telerik:RadComboBoxItem runat="server" Text="Edit" Value="Edit" />
<telerik:RadComboBoxItem runat="server" Text="Delete" Value="Delete" />
<telerik:RadComboBoxItem runat="server" Text="ActionC" Value="ActionC" />
</Items>
</telerik:RadComboBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</telerik:GridTemplateColumn>
6 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 Jul 2009, 06:47 AM
Hello,
Try out the following code snippet and see whether it suits your scenario.
ASPX:
C#:
Hope this would help you.
-Shinu.
Try out the following code snippet and see whether it suits your scenario.
ASPX:
| <telerik:RadGrid ID="RadGrid1" runat="server" OnItemCommand="RadGrid1_ItemCommand"> |
| <MasterTableView DataSourceID="SqlDataSource1"> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="GridTemplateColumn1" AllowFiltering="False"> |
| <ItemTemplate> |
| <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" Text="Select Action..." Value="SelectAction" /> |
| <telerik:RadComboBoxItem runat="server" Text="Edit" Value="Edit" /> |
| <telerik:RadComboBoxItem runat="server" Text="Delete" Value="Delete" /> |
| <telerik:RadComboBoxItem runat="server" Text="ActionC" Value="ActionC" /> |
| </Items> |
| </telerik:RadComboBox> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Center"></ItemStyle> |
| </telerik:GridTemplateColumn> |
| . . . |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <telerik:RadWindowManager ID="RadWindowManager1" runat="server"> |
| <Windows> |
| <telerik:RadWindow ID="RadWindow1" runat="server"> |
| </telerik:RadWindow> |
| </Windows> |
| </telerik:RadWindowManager> |
C#:
| protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| RadComboBox combo = (RadComboBox)o; |
| GridDataItem item = (GridDataItem)combo.NamingContainer; |
| if (combo.SelectedItem.Text == "Edit") |
| { |
| item.FireCommandEvent("Edit", ""); // Set as in Editmode |
| } |
| else if (combo.SelectedItem.Text == "Delete") |
| { |
| item.FireCommandEvent("Delete", ""); |
| } |
| else if (combo.SelectedItem.Text == "ActionC") |
| { |
| //Opens the window |
| RadWindowManager1.Windows[0].NavigateUrl = "Default.aspx?id="+item["CustomerID"].Text.ToString(); // Set the Url with parameters |
| RadWindowManager1.Windows[0].VisibleOnPageLoad = true; |
| } |
| } |
-Shinu.
0
sf
Top achievements
Rank 1
answered on 22 Jul 2009, 09:15 AM
thanks Shinu very very much for your quick help, it works perfectly!
I have 2 more scenarios, could u help further plz.
1. for the delete option I want to have a popup confirmation box appear before actual deletion
2. how do I make another action ActionD which opens a new page (not a radwindow);
0
Shinu
Top achievements
Rank 2
answered on 22 Jul 2009, 09:58 AM
Hi,
1. One suggestion would be attaching clientside event OnClientSelectedIndexChanging to RadComboBox and then check for the selected item. Show confirmation message if the selected item is Delete and cancel the event if confirmation returns False.
JavaScript:
2. You can redirect the page using the Response.Redirect method.
C#:
-Shinu.
1. One suggestion would be attaching clientside event OnClientSelectedIndexChanging to RadComboBox and then check for the selected item. Show confirmation message if the selected item is Delete and cancel the event if confirmation returns False.
JavaScript:
| <script type="text/javascript"> |
| function OnClientSelectedIndexChanging(sender, eventArgs) |
| { |
| var item = eventArgs.get_item(); |
| var text = item.get_value(); |
| if(text == "Delete") |
| { |
| eventArgs.set_cancel(!confirm("Do you want to delete the item ?")); |
| } |
| } |
| </script> |
2. You can redirect the page using the Response.Redirect method.
C#:
| protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| RadComboBox combo = (RadComboBox)o; |
| GridDataItem item = (GridDataItem)combo.NamingContainer; |
| if (combo.SelectedItem.Text == "Edit") |
| { |
| item.FireCommandEvent("Edit", ""); |
| } |
| . . . |
| else if (combo.SelectedItem.Text == "ActionD") |
| { |
| Response.Redirect("Default.aspx"); |
| } |
| } |
-Shinu.
0
SoniTek
Top achievements
Rank 1
answered on 11 Feb 2010, 05:04 AM
Hi Shinu,
How would you code to close RadWindow on button click and rebind RadGrid?
Thanks
How would you code to close RadWindow on button click and rebind RadGrid?
Thanks
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2010, 07:39 AM
Hi,
If the button is placed in radwindow page, then you can use the following code in order to close the radwindow.
JavaScript:
Now for rebinding the grid on clossing the window, attach OnClientClose event to window, then in the event handler invoke an ajaxRequest(). Then from the server side, rebind the grid.
javascript:
cs:
Also set the AjaxSetting as shown below.
aspx:
-Shinu.
If the button is placed in radwindow page, then you can use the following code in order to close the radwindow.
JavaScript:
| function GetRadWindow() |
| { |
| var oWindow = null; |
| if (window.radWindow) |
| oWindow = window.radWindow; |
| else if (window.frameElement.radWindow) |
| oWindow = window.frameElement.radWindow; |
| return oWindow; |
| } |
| function closeWindow() |
| { |
| var oWnd = GetRadWindow(); |
| oWnd.close(); |
| } |
Now for rebinding the grid on clossing the window, attach OnClientClose event to window, then in the event handler invoke an ajaxRequest(). Then from the server side, rebind the grid.
javascript:
| <script type="text/javascript"> |
| function OnClientClose() |
| { |
| $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(); |
| } |
| </script> |
cs:
| protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
| { |
| RadGrid1.Rebind(); |
| } |
Also set the AjaxSetting as shown below.
aspx:
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
-Shinu.
0
SoniTek
Top achievements
Rank 1
answered on 28 Feb 2010, 07:08 PM
Hi Shinu,
I have this working on IE but unable to get it to work on Firefox and Safari. It does not save.