Hi All,
In my scenario, I need to enable few buttons when user selects a row in the radgrid. I need to handle it without going to server(in client side).
Once, the user selects rows from grid, I need to enable buttons . how do i do this.
Pls help.
Thanks,
ZR
In my scenario, I need to enable few buttons when user selects a row in the radgrid. I need to handle it without going to server(in client side).
Once, the user selects rows from grid, I need to enable buttons . how do i do this.
Pls help.
Thanks,
ZR
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 10 Jul 2009, 05:13 AM
Hi Zaheka,
Give a try with the following approach.
ASPX:
CS:
Regards
Shinu.
Give a try with the following approach.
ASPX:
| <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > |
| <ItemTemplate> |
| <asp:Button ID="Button4" runat="server" Enabled="false" Text="Hello" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
CS:
| <script type="text/javascript" > |
| function RowSelecting(sender, args) |
| { |
| args.get_gridDataItem().findElement("Button4").disabled=false; |
| } |
| </script> |
Regards
Shinu.
0
Ayesha
Top achievements
Rank 1
answered on 10 Jul 2009, 12:57 PM
Hi Shinu,
Thanks for the immediate reponse. appreciate it.
But how do i call that javascript fn? Moreover, all this happens in an user control. so, how do i invoke my js fn()
and I'm using a datacolumn (not grid template column).
Can you explain this to me.
Thanks,
ZR
Thanks for the immediate reponse. appreciate it.
But how do i call that javascript fn? Moreover, all this happens in an user control. so, how do i invoke my js fn()
and I'm using a datacolumn (not grid template column).
Can you explain this to me.
Thanks,
ZR
0
Shinu
Top achievements
Rank 2
answered on 13 Jul 2009, 08:50 AM
Hi Zaheka,
You can wire up the OnRowSelecting client event for the RadGrid in the UserControl and perform the desired operation inside the client event. I hope you are using a GridButtonColumn and trying to disable the button for the selected row using Javascript. If so try with the following code snippet and see whether it helps.
ASCX:
Regards
Shinu
You can wire up the OnRowSelecting client event for the RadGrid in the UserControl and perform the desired operation inside the client event. I hope you are using a GridButtonColumn and trying to disable the button for the selected row using Javascript. If so try with the following code snippet and see whether it helps.
ASCX:
| <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" PageSize="5" DataSourceID="SqlDataSource1" GridLines="None"> |
| <MasterTableView AutoGenerateColumns="False" CellSpacing="-1" DataKeyNames="ProductID" |
| DataSourceID="SqlDataSource1"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="ProductID" DataType="System.Int32" HeaderText="ProductID" |
| ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID"> |
| </telerik:GridBoundColumn> |
| <telerik:GridButtonColumn Text="Delete" UniqueName="BtnCol" ButtonType="PushButton" ></telerik:GridButtonColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting AllowRowSelect="true" /> |
| <ClientEvents OnRowSelecting="OnRowSelecting" OnRowCreated="OnRowCreated" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName] FROM [Products]"></asp:SqlDataSource> // Client side code |
| <script type="text/javascript"> |
| function OnRowSelecting(sender, args) |
| { |
| var mastertable = sender.get_masterTableView(); |
| var cell = mastertable.getCellByColumnUniqueName(args.get_gridDataItem(), "BtnCol") |
| cell.lastChild.disabled=true; |
| } |
| function RowCreated(sender, eventArgs) |
| { |
| } |
| </script> |
Regards
Shinu